gh-110171: libregrtest always sets random.seed (#110172)

This commit is contained in:
Nikita Sobolev 2023-10-04 09:42:12 +03:00 committed by GitHub
parent 5b9a3fd6a0
commit 1465386720
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 16 deletions

View file

@ -392,7 +392,7 @@ class ParseArgsTestCase(unittest.TestCase):
self.assertEqual(regrtest.num_workers, -1)
self.assertEqual(regrtest.want_rerun, rerun)
self.assertTrue(regrtest.randomize)
self.assertIsNone(regrtest.random_seed)
self.assertIsInstance(regrtest.random_seed, int)
self.assertTrue(regrtest.fail_env_changed)
self.assertTrue(regrtest.fail_rerun)
self.assertTrue(regrtest.print_slowest)
@ -663,7 +663,7 @@ class BaseTestCase(unittest.TestCase):
def parse_random_seed(self, output):
match = self.regex_search(r'Using random seed ([0-9]+)', output)
randseed = int(match.group(1))
self.assertTrue(0 <= randseed <= 100_000_000, randseed)
self.assertTrue(0 <= randseed, randseed)
return randseed
def run_command(self, args, input=None, exitcode=0, **kw):
@ -950,6 +950,10 @@ class ArgsTestCase(BaseTestCase):
test_random2 = int(match.group(1))
self.assertEqual(test_random2, test_random)
# check that random.seed is used by default
output = self.run_tests(test, exitcode=EXITCODE_NO_TESTS_RAN)
self.assertIsInstance(self.parse_random_seed(output), int)
def test_fromfile(self):
# test --fromfile
tests = [self.create_test() for index in range(5)]