I get integration tests with a database, and I would like to have a structure that looks something like this:
class OracleMixin(object): oracle = True
Thus, I can run SQL Server tests and Oracle tests separately as follows:
nosetests -a oracle nosetests -a sql_server
Or all integration tests:
nosetests -a integration
However, it looks like the nose will only look for attributes in a subclass, not a base class. Thus, I have to define test classes like this, or the tests will not run:
class test_OracleSomeTests(SomeTests, OracleMixin): oracle = True integration = True class test_SqlServerSomeTests(SomeTests, SqlServerMixin): sql_server = True integration = True
It is a little tiring to maintain. Any ideas how to get around this? If I were just dealing with one base class, I would just use a metaclass and define attributes for each class. But I feel awkward about having a metaclass for a test class, a metaclass for Oracle, and a metaclass for SQL Server.
source share