[TIP] Injecting clients into a test : nose Plugin difficulties

Prasanna Santhanam Prasanna.Santhanam at citrix.com
Tue Jul 17 04:45:13 PDT 2012


We have some legacy tests that I am trying to run through nose. All test
classes are subclassed from "BusinessTestCase" which in turn inherits from
unittest.TestCase. I figured a plugin would identify all these classes and run
them and so started writing one. I looked at the IPluginInterface and have got
nose to successfully identify the test classes by overloading the wantClass

However - BusinessTestCase also injects a database connection object into each
test class during setUpClass. This is used to make some assertions against
certain SQL queries on the data set. I tried to inject this database client
object using prepareTest that I overloaded but this does not take effect. Am I
right in overloading prepareTest for achieving this?


More information about the testing-in-python mailing list