Re:Job Description as runnable python UnitTest
by digitallogic on Friday September 03, 2010 @10:59AM
(#1659774)
Referencing the 'candidate' variable from within the test case is not a good approach as it's referencing a module global instead of an attribute. Additionally, it only exists when the module is executed directly, so if it's imported and run in a different manner a name error will result for every test that references.
As for the TestProgram, it's inheriting routines from the base class in the unittest module that do introspection to find all test fixtures.
It's weird to me that the "candidate" referenced by FoundationEngineerTestCase is the same candidate instantiated at the bottom of the file, without ever being explicitly passed into an instance of that class. I would have expected:
Furthermore, how is CandidateTestProgram connected to FoundationEngineerTestCase? Does it do a global search for subclasses of unittest.TestCase, then instantiate and execute them?