diff options
author | Steve Purcell <steve@pythonconsulting.com> | 2001-08-08 07:57:26 (GMT) |
---|---|---|
committer | Steve Purcell <steve@pythonconsulting.com> | 2001-08-08 07:57:26 (GMT) |
commit | e00dde2087db2c211f9c9267659d37e3306f79d8 (patch) | |
tree | 8849d9734b6da55dff46675de13e297e289757df | |
parent | a38d2608bc39985192864741f69843ee2c37eb04 (diff) | |
download | cpython-e00dde2087db2c211f9c9267659d37e3306f79d8.zip cpython-e00dde2087db2c211f9c9267659d37e3306f79d8.tar.gz cpython-e00dde2087db2c211f9c9267659d37e3306f79d8.tar.bz2 |
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.
-rw-r--r-- | Lib/unittest.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/unittest.py b/Lib/unittest.py index c3faa10..480e825 100644 --- a/Lib/unittest.py +++ b/Lib/unittest.py @@ -432,16 +432,17 @@ class TestLoader: for part in parts: obj = getattr(obj, part) + import unittest if type(obj) == types.ModuleType: return self.loadTestsFromModule(obj) - elif type(obj) == types.ClassType and issubclass(obj, TestCase): + elif type(obj) == types.ClassType and issubclass(obj, unittest.TestCase): return self.loadTestsFromTestCase(obj) elif type(obj) == types.UnboundMethodType: return obj.im_class(obj.__name__) elif callable(obj): test = obj() - if not isinstance(test, TestCase) and \ - not isinstance(test, TestSuite): + if not isinstance(test, unittest.TestCase) and \ + not isinstance(test, unittest.TestSuite): raise ValueError, \ "calling %s returned %s, not a test" % (obj,test) return test |