summaryrefslogtreecommitdiff
path: root/testrepository/tests/test_testcommand.py
diff options
context:
space:
mode:
Diffstat (limited to 'testrepository/tests/test_testcommand.py')
-rw-r--r--testrepository/tests/test_testcommand.py27
1 files changed, 18 insertions, 9 deletions
diff --git a/testrepository/tests/test_testcommand.py b/testrepository/tests/test_testcommand.py
index bbe4ac8..b5b3374 100644
--- a/testrepository/tests/test_testcommand.py
+++ b/testrepository/tests/test_testcommand.py
@@ -362,7 +362,7 @@ class TestTestCommand(ResourcedTestCase):
self.assertEqual(1, len(partitions[0]))
self.assertEqual(1, len(partitions[1]))
- def test_partition_tests_with_group_regex(self):
+ def test_partition_tests_with_grouping(self):
repo = memory.RepositoryFactory().initialise('memory:')
result = repo.get_inserter()
result.startTestRun()
@@ -381,17 +381,26 @@ class TestTestCommand(ResourcedTestCase):
'TestCase2.fast2', 'TestCase4.test',
'testdir.testfile.TestCase5.test'])
regex = 'TestCase[0-5]'
- group_tags = fixture.filter_test_groups(test_ids, regex)
- partitions = fixture.partition_tests(test_ids, 2, group_tags)
+ def group_id(test_id, regex=re.compile('TestCase[0-5]')):
+ match = regex.match(test_id)
+ if match:
+ return match.group(0)
+ # There isn't a public way to define a group callback [as yet].
+ fixture._group_callback = group_id
+ partitions = fixture.partition_tests(test_ids, 2)
+ # Timed groups are deterministic:
+ self.assertTrue('TestCase2.fast1' in partitions[0])
+ self.assertTrue('TestCase2.fast2' in partitions[0])
self.assertTrue('TestCase1.slow' in partitions[1])
self.assertTrue('TestCase1.fast' in partitions[1])
self.assertTrue('TestCase1.fast2' in partitions[1])
- self.assertTrue('TestCase3.test2' in partitions[1])
- self.assertTrue('TestCase3.test1' in partitions[1])
- self.assertTrue('TestCase4.test' in partitions[1])
- self.assertTrue('testdir.testfile.TestCase5.test' in partitions[0])
- self.assertTrue('TestCase2.fast1' in partitions[0])
- self.assertTrue('TestCase2.fast2' in partitions[0])
+ # Untimed groups just need to be kept together:
+ if 'TestCase3.test1' in partitions[0]:
+ self.assertTrue('TestCase3.test2' in partitions[0])
+ if 'TestCase4.test' not in partitions[0]:
+ self.assertTrue('TestCase4.test' in partitions[1])
+ if 'testdir.testfile.TestCase5.test' not in partitions[0]:
+ self.assertTrue('testdir.testfile.TestCase5.test' in partitions[1])
def test_run_tests_with_instances(self):
# when there are instances and no instance_execute, run_tests acts as