mirror of
https://github.com/python/cpython.git
synced 2025-09-20 15:40:32 +00:00
gh-127146: Some expected failures in Emscripten time tests (#127843)
Disables two tests in the test_time suite, and adjusts test_os to reflect precision limits in Emscripten.
This commit is contained in:
parent
c84928ed6d
commit
41f29e5d16
2 changed files with 25 additions and 7 deletions
|
@ -805,6 +805,20 @@ class UtimeTests(unittest.TestCase):
|
||||||
set_time(filename, (atime_ns, mtime_ns))
|
set_time(filename, (atime_ns, mtime_ns))
|
||||||
st = os.stat(filename)
|
st = os.stat(filename)
|
||||||
|
|
||||||
|
if support.is_emscripten:
|
||||||
|
# Emscripten timestamps are roundtripped through a 53 bit integer of
|
||||||
|
# nanoseconds. If we want to represent ~50 years which is an 11
|
||||||
|
# digits number of seconds:
|
||||||
|
# 2*log10(60) + log10(24) + log10(365) + log10(60) + log10(50)
|
||||||
|
# is about 11. Because 53 * log10(2) is about 16, we only have 5
|
||||||
|
# digits worth of sub-second precision.
|
||||||
|
# Some day it would be good to fix this upstream.
|
||||||
|
delta=1e-5
|
||||||
|
self.assertAlmostEqual(st.st_atime, atime_ns * 1e-9, delta=1e-5)
|
||||||
|
self.assertAlmostEqual(st.st_mtime, mtime_ns * 1e-9, delta=1e-5)
|
||||||
|
self.assertAlmostEqual(st.st_atime_ns, atime_ns, delta=1e9 * 1e-5)
|
||||||
|
self.assertAlmostEqual(st.st_mtime_ns, mtime_ns, delta=1e9 * 1e-5)
|
||||||
|
else:
|
||||||
if support_subsecond:
|
if support_subsecond:
|
||||||
self.assertAlmostEqual(st.st_atime, atime_ns * 1e-9, delta=1e-6)
|
self.assertAlmostEqual(st.st_atime, atime_ns * 1e-9, delta=1e-6)
|
||||||
self.assertAlmostEqual(st.st_mtime, mtime_ns * 1e-9, delta=1e-6)
|
self.assertAlmostEqual(st.st_mtime, mtime_ns * 1e-9, delta=1e-6)
|
||||||
|
|
|
@ -116,6 +116,7 @@ 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.skipIf(support.is_emscripten, "Fails to find clock")
|
||||||
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)
|
||||||
|
@ -539,6 +540,9 @@ class TimeTestCase(unittest.TestCase):
|
||||||
@unittest.skipIf(
|
@unittest.skipIf(
|
||||||
support.is_wasi, "process_time not available on WASI"
|
support.is_wasi, "process_time not available on WASI"
|
||||||
)
|
)
|
||||||
|
@unittest.skipIf(
|
||||||
|
support.is_emscripten, "process_time present but doesn't exclude sleep"
|
||||||
|
)
|
||||||
def test_process_time(self):
|
def test_process_time(self):
|
||||||
# process_time() should not include time spend during a sleep
|
# process_time() should not include time spend during a sleep
|
||||||
start = time.process_time()
|
start = time.process_time()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue