diff options
| author | Chris Jerdonek <chris.jerdonek@gmail.com> | 2021-07-09 16:12:17 -0400 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-07-12 06:36:12 +0200 |
| commit | 5848b3a1d70f09aaf598d794569ad758183f41db (patch) | |
| tree | 31173454b72160619bb456ec6c47edb303627874 /tests/test_runner | |
| parent | 6f60fa97b0b501ef7cc77e16392654bf27ec8db3 (diff) | |
Fixed #32914 -- Prevented test --shuffle from skipping test methods.
"test --shuffle" skipped test methods when test classes were mixed.
This changes runner.py's reorder_tests() to group by TestCase class.
Regression in 90ba716bf060ee7fef79dc230b0b20644839069f.
Diffstat (limited to 'tests/test_runner')
| -rw-r--r-- | tests/test_runner/tests.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/test_runner/tests.py b/tests/test_runner/tests.py index 77a756a1de..3a535f3e1e 100644 --- a/tests/test_runner/tests.py +++ b/tests/test_runner/tests.py @@ -181,6 +181,19 @@ class TestSuiteTests(SimpleTestCase): 'Tests1.test1', 'Tests1.test2', 'Tests2.test2', 'Tests2.test1', ]) + def test_reorder_tests_same_type_consecutive(self): + """Tests of the same type are made consecutive.""" + tests = self.make_tests() + # Move the last item to the front. + tests.insert(0, tests.pop()) + self.assertTestNames(tests, expected=[ + 'Tests2.test2', 'Tests1.test1', 'Tests1.test2', 'Tests2.test1', + ]) + reordered_tests = reorder_tests(tests, classes=[]) + self.assertTestNames(reordered_tests, expected=[ + 'Tests2.test2', 'Tests2.test1', 'Tests1.test1', 'Tests1.test2', + ]) + def test_reorder_tests_random(self): tests = self.make_tests() # Choose a seed that shuffles both the classes and methods. @@ -191,6 +204,19 @@ class TestSuiteTests(SimpleTestCase): 'Tests2.test1', 'Tests2.test2', 'Tests1.test2', 'Tests1.test1', ]) + def test_reorder_tests_random_mixed_classes(self): + tests = self.make_tests() + # Move the last item to the front. + tests.insert(0, tests.pop()) + shuffler = Shuffler(seed=9) + self.assertTestNames(tests, expected=[ + 'Tests2.test2', 'Tests1.test1', 'Tests1.test2', 'Tests2.test1', + ]) + reordered_tests = reorder_tests(tests, classes=[], shuffler=shuffler) + self.assertTestNames(reordered_tests, expected=[ + 'Tests2.test1', 'Tests2.test2', 'Tests1.test2', 'Tests1.test1', + ]) + def test_reorder_tests_reverse_with_duplicates(self): class Tests1(unittest.TestCase): def test1(self): |
