summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_os.py
diff options
context:
space:
mode:
authorHood Chatham <roberthoodchatham@gmail.com>2024-12-12 01:11:00 (GMT)
committerGitHub <noreply@github.com>2024-12-12 01:11:00 (GMT)
commit41f29e5d16c314790559e563ce5ca0334fcd54df (patch)
treee157825bf153e5b8ed761300a753b1d5411a40eb /Lib/test/test_os.py
parentc84928ed6de105696be24859e03f3ab27e11daf6 (diff)
downloadcpython-41f29e5d16c314790559e563ce5ca0334fcd54df.zip
cpython-41f29e5d16c314790559e563ce5ca0334fcd54df.tar.gz
cpython-41f29e5d16c314790559e563ce5ca0334fcd54df.tar.bz2
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.
Diffstat (limited to 'Lib/test/test_os.py')
-rw-r--r--Lib/test/test_os.py28
1 files changed, 21 insertions, 7 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index f3d2ceb..8aac929 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -805,14 +805,28 @@ class UtimeTests(unittest.TestCase):
set_time(filename, (atime_ns, mtime_ns))
st = os.stat(filename)
- if support_subsecond:
- self.assertAlmostEqual(st.st_atime, atime_ns * 1e-9, delta=1e-6)
- self.assertAlmostEqual(st.st_mtime, mtime_ns * 1e-9, delta=1e-6)
+ 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:
- self.assertEqual(st.st_atime, atime_ns * 1e-9)
- self.assertEqual(st.st_mtime, mtime_ns * 1e-9)
- self.assertEqual(st.st_atime_ns, atime_ns)
- self.assertEqual(st.st_mtime_ns, mtime_ns)
+ if support_subsecond:
+ self.assertAlmostEqual(st.st_atime, atime_ns * 1e-9, delta=1e-6)
+ self.assertAlmostEqual(st.st_mtime, mtime_ns * 1e-9, delta=1e-6)
+ else:
+ self.assertEqual(st.st_atime, atime_ns * 1e-9)
+ self.assertEqual(st.st_mtime, mtime_ns * 1e-9)
+ self.assertEqual(st.st_atime_ns, atime_ns)
+ self.assertEqual(st.st_mtime_ns, mtime_ns)
def test_utime(self):
def set_time(filename, ns):