Closed danjamesmay closed 6 years ago
First, your output doesn't look right. I get:
I AM SETTING UP
mytest.test_tearing_down ... I AM SETTING UP
I AM TEARING DOWN
ok
I AM TEARING DOWN
----------------------------------------------------------------------
Ran 1 test in 0.001s
OK
You're running into this because of how you named the functions. setup
and teardown
are "reserved" for module-level setup and teardown of test fixtures. Then you have a test case that then uses those function as a setup and teardown. The combined effect that both setup and teardown are being called twice.
Rename the functions to something else (see the link above), and you should be good.
I am writing nose test functions in a file.
I am calling
nosetests -s -v && nosetests --version
to activate the test runner.My test code is as follows:
Output:
Tried with versions:
1.3.0, 1.1.0, 1.0.0
. Same output.What on earth is going on?
I originally was trying to use a teardown method to rename a database back to its original name after it is renamed by the test. This fault injection mechanism was to test how the client reacts when it can't connect to my database. This was failing because the teardown was running twice.
Now I have moved this teardown to the bottom of the test, so it is not guaranteed to run, which is not ideal.