Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e00dde2

Browse files
committed
Merged in bugfix from PyUnit CVS for problem reported by Gary Todd.
If 'unittest.py' was run from the command line with the name of a test case class as a parameter, it failed with an ugly error. (Which was a shame, because the documentation says you can do that.) The problem was the old 'is the class X that you imported from me the same as my class X?' gotcha.
1 parent a38d260 commit e00dde2

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

Lib/unittest.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,16 +432,17 @@ def loadTestsFromName(self, name, module=None):
432432
for part in parts:
433433
obj = getattr(obj, part)
434434

435+
import unittest
435436
if type(obj) == types.ModuleType:
436437
return self.loadTestsFromModule(obj)
437-
elif type(obj) == types.ClassType and issubclass(obj, TestCase):
438+
elif type(obj) == types.ClassType and issubclass(obj, unittest.TestCase):
438439
return self.loadTestsFromTestCase(obj)
439440
elif type(obj) == types.UnboundMethodType:
440441
return obj.im_class(obj.__name__)
441442
elif callable(obj):
442443
test = obj()
443-
if not isinstance(test, TestCase) and \
444-
not isinstance(test, TestSuite):
444+
if not isinstance(test, unittest.TestCase) and \
445+
not isinstance(test, unittest.TestSuite):
445446
raise ValueError, \
446447
"calling %s returned %s, not a test" % (obj,test)
447448
return test

0 commit comments

Comments
 (0)