Kaydet (Commit) 86566702 authored tarafından Benjamin Peterson's avatar Benjamin Peterson Kaydeden (comit) GitHub

weaken pthread_getcpuclockid test (more bpo-31596) (#3904)

There just isn't much we can assert in a portable way.
üst 7faf7e50
...@@ -85,20 +85,13 @@ class TimeTestCase(unittest.TestCase): ...@@ -85,20 +85,13 @@ class TimeTestCase(unittest.TestCase):
'need time.pthread_getcpuclockid()') 'need time.pthread_getcpuclockid()')
@unittest.skipUnless(hasattr(time, 'clock_gettime'), @unittest.skipUnless(hasattr(time, 'clock_gettime'),
'need time.clock_gettime()') 'need time.clock_gettime()')
@unittest.skipUnless(hasattr(time, 'CLOCK_THREAD_CPUTIME_ID'),
'need time.CLOCK_THREAD_CPUTIME_ID')
def test_pthread_getcpuclockid(self): def test_pthread_getcpuclockid(self):
clk_id = time.pthread_getcpuclockid(threading.get_ident()) clk_id = time.pthread_getcpuclockid(threading.get_ident())
self.assertTrue(type(clk_id) is int) self.assertTrue(type(clk_id) is int)
self.assertNotEqual(clk_id, time.CLOCK_THREAD_CPUTIME_ID) self.assertNotEqual(clk_id, time.CLOCK_THREAD_CPUTIME_ID)
# This should suffice to show that both calls are measuring the same clock.
t1 = time.clock_gettime(clk_id) t1 = time.clock_gettime(clk_id)
t2 = time.clock_gettime(time.CLOCK_THREAD_CPUTIME_ID) t2 = time.clock_gettime(clk_id)
t3 = time.clock_gettime(clk_id)
t4 = time.clock_gettime(time.CLOCK_THREAD_CPUTIME_ID)
self.assertLessEqual(t1, t2) self.assertLessEqual(t1, t2)
self.assertLessEqual(t2, t3)
self.assertLessEqual(t3, t4)
@unittest.skipUnless(hasattr(time, 'clock_getres'), @unittest.skipUnless(hasattr(time, 'clock_getres'),
'need time.clock_getres()') 'need time.clock_getres()')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment