On 06/11/2012 12:04 PM, John Garbutt wrote: > Hi, > > I am trying to run tests like "test_xenapi" and "test_libvirt" by themselves > do things like: > nosetests test_xenapi > But it does work, I get DB errors relating to missing tables. However, I can > successfully run all the tests. > > The way I understand it: > - nova.tests.__init__.py setup() does the database setup > - nova.test.py TestCase.setUp() does the resetting of the db > It is almost like doing "nosetests test_asdf" skips the database setup in > nova.tests.__init__.py, is that correct?
I believe this is because "nosetests test_asdf" is taking advantage of the "where=nova/tests" in setup.cfg and actually just starts the test from there. So whereas run_tests.py aliased "run_tests.sh test_asdf" to "run_tests nova.tests.test_asdf", I believe nosetests is now actually changing directory into nose/tests and then running, so is not actually loading nova/tests/__init__.py because it's not resolving the library path that way. > Any ideas on how to run tests individually, but still get the database > correclty initialized? Am I just calling the tests incorrectly? I like the patch that was submitted for this, actually. Part of the intent behind the recent patches it to get our test runner behaving a little bit more normal and to put extra things we need inside of test fixtures and the like so that as we continue to grow we can take advantage of the work of other people on things like automatic test run parallelization and what not. So actually, doing database setup in the test fixture is the more correct way to do things - whereas just relying on __init__ import semantics to do it is a bit of a hack. _______________________________________________ Mailing list: https://launchpad.net/~openstack Post to : openstack@lists.launchpad.net Unsubscribe : https://launchpad.net/~openstack More help : https://help.launchpad.net/ListHelp