diff options
Diffstat (limited to 'Lib/unittest/suite.py')
-rw-r--r-- | Lib/unittest/suite.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/Lib/unittest/suite.py b/Lib/unittest/suite.py index 633af5cb085..cde5d385ed1 100644 --- a/Lib/unittest/suite.py +++ b/Lib/unittest/suite.py @@ -31,9 +31,6 @@ class BaseTestSuite(object): def __ne__(self, other): return not self == other - # Can't guarantee hash invariant, so flag as unhashable - __hash__ = None - def __iter__(self): return iter(self._tests) @@ -45,7 +42,7 @@ class BaseTestSuite(object): def addTest(self, test): # sanity checks - if not hasattr(test, '__call__'): + if not callable(test): raise TypeError("{} is not callable".format(repr(test))) if isinstance(test, type) and issubclass(test, (case.TestCase, TestSuite)): @@ -54,7 +51,7 @@ class BaseTestSuite(object): self._tests.append(test) def addTests(self, tests): - if isinstance(tests, basestring): + if isinstance(tests, str): raise TypeError("tests must be an iterable of tests, not a string") for test in tests: self.addTest(test) @@ -170,6 +167,7 @@ class TestSuite(BaseTestSuite): self._handleModuleTearDown(result) + result._moduleSetUpFailed = False try: module = sys.modules[currentModule] @@ -180,7 +178,7 @@ class TestSuite(BaseTestSuite): _call_if_exists(result, '_setupStdout') try: setUpModule() - except Exception, e: + except Exception as e: if isinstance(result, _DebugResult): raise result._moduleSetUpFailed = True @@ -239,7 +237,7 @@ class TestSuite(BaseTestSuite): _call_if_exists(result, '_setupStdout') try: tearDownClass() - except Exception, e: + except Exception as e: if isinstance(result, _DebugResult): raise className = util.strclass(previousClass) |