- commit
- 5b257c932b01485db2170c21116f5ef06754b76b
- parent
- c383ca69e8b62de8bd033d2b664192d7a70ea35e
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2026-04-12 17:29
reduce test timing precision
Diffstat
| M | tests/test_compat.py | 4 | ++-- |
| M | tests/test_subprocess.py | 4 | ++-- |
| M | tests/utils.py | 2 | +- |
3 files changed, 5 insertions, 5 deletions
diff --git a/tests/test_compat.py b/tests/test_compat.py
@@ -9,7 +9,7 @@ import xiio 9 9 10 10 class TestOnAsyncIO(unittest.IsolatedAsyncioTestCase): 11 11 @contextlib.contextmanager12 -1 def assert_duration(self, expected, *, places=2):-1 12 def assert_duration(self, expected, *, places=1): 13 13 start = time.monotonic() 14 14 try: 15 15 yield @@ -22,7 +22,7 @@ class TestOnAsyncIO(unittest.IsolatedAsyncioTestCase): 22 22 await xiio.on_asyncio(xiio.sleep(0.1)) 23 23 24 24 async def test_sleep_both(self):25 -1 with self.assert_duration(0.1, places=1):-1 25 with self.assert_duration(0.1): 26 26 await asyncio.gather( 27 27 asyncio.sleep(0.1), 28 28 xiio.on_asyncio(xiio.sleep(0.1)),
diff --git a/tests/test_subprocess.py b/tests/test_subprocess.py
@@ -8,7 +8,7 @@ class TestRunProcess(XiioTestCase): 8 8 async def test_run_process(self): 9 9 cmd = ['sh', '-c', 'sleep 0.1 && echo "Hello World"'] 10 1011 -1 with self.assert_duration(0.1, places=1):-1 11 with self.assert_duration(0.1): 12 12 result = await xiio.run_process(cmd, capture_output=True) 13 13 self.assertEqual(result.returncode, 0) 14 14 self.assertEqual(result.stdout, b'Hello World\n') @@ -19,7 +19,7 @@ class TestRunProcess(XiioTestCase): 19 19 await xiio.run_process(['false'], check=True) 20 20 21 21 async def test_cancel(self):22 -1 with self.assert_duration(0.1, places=1):-1 22 with self.assert_duration(0.1): 23 23 with self.assertRaises(TimeoutError): 24 24 async with xiio.timeout(0.1): 25 25 await xiio.run_process(['sleep', '0.5'])
diff --git a/tests/utils.py b/tests/utils.py
@@ -19,7 +19,7 @@ class XiioTestCase(unittest.TestCase): 19 19 return super()._callTestMethod(wrapper) # ty: ignore[unresolved-attribute] 20 20 21 21 @contextlib.contextmanager22 -1 def assert_duration(self, expected, *, places=2):-1 22 def assert_duration(self, expected, *, places=1): 23 23 start = time.monotonic() 24 24 try: 25 25 yield