xiio

really simple async runtime
git clone https://git.ce9e.org/xiio.git

commit
6b9965a49151195a363b7eb06f53a6379e1102ea
parent
16ee9628d0488dafc035354ec7a98d8675176539
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2026-02-27 00:04
simple sync test functions

Diffstat

M tests.py 34 +++++++++++++++++++++++++++++++++-

1 files changed, 33 insertions, 1 deletions


diff --git a/tests.py b/tests.py

@@ -16,4 +16,36 @@ class XiioTestCase(unittest.TestCase):
   16    16 
   17    17 
   18    18 class TestRun(XiioTestCase):
   19    -1     pass
   -1    19     def test_sleep(self):
   -1    20         def foo():
   -1    21             time.sleep(0.1)
   -1    22             return 'Hello World'
   -1    23 
   -1    24         with self.assert_duration(0.1):
   -1    25             result = foo()
   -1    26         self.assertEqual(result, 'Hello World')
   -1    27 
   -1    28     def test_runs_cleanup_on_error_while_paused(self):
   -1    29         stack = []
   -1    30 
   -1    31         def foo():
   -1    32             try:
   -1    33                 time.sleep(0.1)
   -1    34             finally:
   -1    35                 stack.append(1)
   -1    36 
   -1    37         with mock.patch('time.sleep', side_effect=KeyboardInterrupt):
   -1    38             with self.assertRaises(KeyboardInterrupt):
   -1    39                 foo()
   -1    40         self.assertEqual(stack, [1])
   -1    41 
   -1    42     def test_waits_for_cleanup(self):
   -1    43         def foo():
   -1    44             try:
   -1    45                 raise ValueError
   -1    46             finally:
   -1    47                 time.sleep(0.1)
   -1    48 
   -1    49         with self.assertRaises(ValueError):
   -1    50             with self.assert_duration(0.1):
   -1    51                 foo()