Allow tests to be run twice
This commit is contained in:
@@ -639,6 +639,8 @@ class TestCase(unittest.TestCase):
|
||||
"super(%s, self).tearDown() from your tearDown()."
|
||||
% (sys.modules[self.__class__.__module__].__file__,
|
||||
self.__class__.__name__))
|
||||
self.__setup_called = False
|
||||
self.__teardown_called = False
|
||||
return ret
|
||||
|
||||
def _get_test_method(self):
|
||||
|
||||
@@ -1265,6 +1265,18 @@ class TestSetupTearDown(TestCase):
|
||||
"...ValueError...File...testtools/tests/test_testcase.py...",
|
||||
ELLIPSIS))
|
||||
|
||||
def test_runTwice(self):
|
||||
# Tests can be run twice.
|
||||
class NormalTest(TestCase):
|
||||
def test_method(self):
|
||||
pass
|
||||
test = NormalTest('test_method')
|
||||
result = unittest.TestResult()
|
||||
test.run(result)
|
||||
test.run(result)
|
||||
self.expectThat(result.errors, HasLength(0))
|
||||
self.assertThat(result.testsRun, Equals(2))
|
||||
|
||||
|
||||
require_py27_minimum = skipIf(
|
||||
sys.version < '2.7',
|
||||
|
||||
Reference in New Issue
Block a user