Index: unittest.py =================================================================== --- unittest.py (revision 60224) +++ unittest.py (working copy) @@ -412,10 +412,11 @@ def addTest(self, test): # sanity checks + import unittest if not callable(test): raise TypeError("the test to add must be callable") if (isinstance(test, (type, types.ClassType)) and - issubclass(test, (TestCase, TestSuite))): + issubclass(test, (unittest.TestCase, unittest.TestSuite))): raise TypeError("TestCases and TestSuites must be instantiated " "before passing them to addTest()") self._tests.append(test) @@ -499,7 +500,8 @@ def loadTestsFromTestCase(self, testCaseClass): """Return a suite of all tests cases contained in testCaseClass""" - if issubclass(testCaseClass, TestSuite): + import unittest + if issubclass(testCaseClass, unittest.TestSuite): raise TypeError("Test cases should not be derived from TestSuite. Maybe you meant to derive from TestCase?") testCaseNames = self.getTestCaseNames(testCaseClass) if not testCaseNames and hasattr(testCaseClass, 'runTest'): @@ -508,11 +510,12 @@ def loadTestsFromModule(self, module): """Return a suite of all tests cases contained in the given module""" + import unittest tests = [] for name in dir(module): obj = getattr(module, name) if (isinstance(obj, (type, types.ClassType)) and - issubclass(obj, TestCase)): + issubclass(obj, unittest.TestCase)): tests.append(self.loadTestsFromTestCase(obj)) return self.suiteClass(tests) @@ -525,6 +528,7 @@ The method optionally resolves the names relative to a given module. """ + import unittest parts = name.split('.') if module is None: parts_copy = parts[:] @@ -543,7 +547,7 @@ if type(obj) == types.ModuleType: return self.loadTestsFromModule(obj) elif (isinstance(obj, (type, types.ClassType)) and - issubclass(obj, TestCase)): + issubclass(obj, unittest.TestCase)): return self.loadTestsFromTestCase(obj) elif type(obj) == types.UnboundMethodType: return parent(obj.__name__)