|
22 | 22 | import tempfile |
23 | 23 | import threading |
24 | 24 | import textwrap |
| 25 | +import time |
25 | 26 | import types |
26 | 27 | import unittest |
27 | 28 | import unittest.mock |
@@ -907,6 +908,24 @@ def run_python(self, args, isolated=True, **kw): |
907 | 908 |
|
908 | 909 |
|
909 | 910 | class CheckActualTests(BaseTestCase): |
| 911 | + @unittest.skipUnless(hasattr(time, 'clock_settime'), 'requires clock_settime') |
| 912 | + @support.thread_unsafe('changes the enabled test resources') |
| 913 | + def test_system_clock_writes(self): |
| 914 | + from test.libregrtest.single import _parallelize_tests |
| 915 | + from test.test_time import TimeTestCase |
| 916 | + |
| 917 | + names = ('test_clock_settime', 'test_monotonic_settime') |
| 918 | + for resources, expected in (({}, 0), ({'settime': None}, 3), ({}, 0)): |
| 919 | + with (self.subTest(resources=resources), |
| 920 | + unittest.mock.patch.object(support, 'use_resources', resources), |
| 921 | + unittest.mock.patch.object(time, 'clock_settime') as setter): |
| 922 | + suite = unittest.TestSuite(TimeTestCase(name) for name in names) |
| 923 | + _parallelize_tests(suite, 2) |
| 924 | + result = unittest.TestResult() |
| 925 | + suite.run(result) |
| 926 | + self.assertTrue(result.wasSuccessful(), result.errors + result.failures) |
| 927 | + self.assertEqual(setter.call_count, expected) |
| 928 | + |
910 | 929 | def test_finds_expected_number_of_tests(self): |
911 | 930 | """ |
912 | 931 | Check that regrtest appears to find the expected set of tests. |
|
0 commit comments