summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/test
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2013-12-28 19:37:58 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2013-12-28 19:37:58 (GMT)
commitb5c66f8645d78670e836057efb0c5eb7230786d6 (patch)
tree69ba414608f990a487464546e3ad328fcedfe243 /Lib/unittest/test
parent156b3610b883f3d14c1a3d115f00a7e5d2437132 (diff)
downloadcpython-b5c66f8645d78670e836057efb0c5eb7230786d6.zip
cpython-b5c66f8645d78670e836057efb0c5eb7230786d6.tar.gz
cpython-b5c66f8645d78670e836057efb0c5eb7230786d6.tar.bz2
Fix breakage in TestSuite.countTestCases() introduced by issue #11798.
Diffstat (limited to 'Lib/unittest/test')
-rw-r--r--Lib/unittest/test/test_suite.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/Lib/unittest/test/test_suite.py b/Lib/unittest/test/test_suite.py
index 54cec6e..38311ca 100644
--- a/Lib/unittest/test/test_suite.py
+++ b/Lib/unittest/test/test_suite.py
@@ -51,6 +51,9 @@ class Test_TestSuite(unittest.TestCase, TestEquality):
suite = unittest.TestSuite()
self.assertEqual(suite.countTestCases(), 0)
+ # countTestCases() still works after tests are run
+ suite.run(unittest.TestResult())
+ self.assertEqual(suite.countTestCases(), 0)
# "class TestSuite([tests])"
# ...
@@ -63,6 +66,9 @@ class Test_TestSuite(unittest.TestCase, TestEquality):
suite = unittest.TestSuite([])
self.assertEqual(suite.countTestCases(), 0)
+ # countTestCases() still works after tests are run
+ suite.run(unittest.TestResult())
+ self.assertEqual(suite.countTestCases(), 0)
# "class TestSuite([tests])"
# ...
@@ -84,6 +90,14 @@ class Test_TestSuite(unittest.TestCase, TestEquality):
suite_3 = unittest.TestSuite(set(suite_1))
self.assertEqual(suite_3.countTestCases(), 2)
+ # countTestCases() still works after tests are run
+ suite_1.run(unittest.TestResult())
+ self.assertEqual(suite_1.countTestCases(), 2)
+ suite_2.run(unittest.TestResult())
+ self.assertEqual(suite_2.countTestCases(), 2)
+ suite_3.run(unittest.TestResult())
+ self.assertEqual(suite_3.countTestCases(), 2)
+
# "class TestSuite([tests])"
# ...
# "If tests is given, it must be an iterable of individual test cases
@@ -99,6 +113,9 @@ class Test_TestSuite(unittest.TestCase, TestEquality):
suite = unittest.TestSuite(tests())
self.assertEqual(suite.countTestCases(), 2)
+ # countTestCases() still works after tests are run
+ suite.run(unittest.TestResult())
+ self.assertEqual(suite.countTestCases(), 2)
################################################################
### /Tests for TestSuite.__init__
@@ -145,6 +162,9 @@ class Test_TestSuite(unittest.TestCase, TestEquality):
suite = unittest.TestSuite((test1, test2))
self.assertEqual(suite.countTestCases(), 2)
+ # countTestCases() still works after tests are run
+ suite.run(unittest.TestResult())
+ self.assertEqual(suite.countTestCases(), 2)
# "Return the number of tests represented by the this test object.
# ...this method is also implemented by the TestSuite class, which can
@@ -162,6 +182,10 @@ class Test_TestSuite(unittest.TestCase, TestEquality):
parent = unittest.TestSuite((test3, child, Test1('test1')))
self.assertEqual(parent.countTestCases(), 4)
+ # countTestCases() still works after tests are run
+ parent.run(unittest.TestResult())
+ self.assertEqual(parent.countTestCases(), 4)
+ self.assertEqual(child.countTestCases(), 2)
# "Run the tests associated with this suite, collecting the result into
# the test result object passed as result."
@@ -220,6 +244,9 @@ class Test_TestSuite(unittest.TestCase, TestEquality):
self.assertEqual(suite.countTestCases(), 1)
self.assertEqual(list(suite), [test])
+ # countTestCases() still works after tests are run
+ suite.run(unittest.TestResult())
+ self.assertEqual(suite.countTestCases(), 1)
# "Add a ... TestSuite to the suite"
def test_addTest__TestSuite(self):
@@ -233,6 +260,9 @@ class Test_TestSuite(unittest.TestCase, TestEquality):
self.assertEqual(suite.countTestCases(), 1)
self.assertEqual(list(suite), [suite_2])
+ # countTestCases() still works after tests are run
+ suite.run(unittest.TestResult())
+ self.assertEqual(suite.countTestCases(), 1)
# "Add all the tests from an iterable of TestCase and TestSuite
# instances to this test suite."
@@ -392,6 +422,7 @@ class Test_TestSuite(unittest.TestCase, TestEquality):
self.assertEqual(len(result.errors), 1)
self.assertEqual(len(result.failures), 0)
self.assertEqual(result.testsRun, 2)
+ self.assertEqual(suite.countTestCases(), 2)
def test_overriding_call(self):