@@ -24,9 +24,9 @@ def test_mock_clock() -> None:
2424 with pytest .raises (ValueError , match = r"^time can't go backwards$" ):
2525 c .jump (- 1 )
2626 assert c .current_time () == 1.2
27- assert c .deadline_to_sleep_time (1 .1 ) == 0
28- assert c .deadline_to_sleep_time (1.2 ) == 0
29- assert c .deadline_to_sleep_time (1.3 ) > 999999
27+ assert c .deadline_to_sleep_time (- 0 .1 ) == ( 0 , 0 )
28+ assert c .deadline_to_sleep_time (0.0 ) == ( 0 , 0 )
29+ assert c .deadline_to_sleep_time (0.1 ) == ( 999999999 , 0.1 )
3030
3131 with pytest .raises (ValueError , match = r"^rate must be >= 0$" ):
3232 c .rate = - 1
@@ -36,15 +36,15 @@ def test_mock_clock() -> None:
3636 assert c .current_time () == 1.2
3737 REAL_NOW += 1
3838 assert c .current_time () == 3.2
39- assert c .deadline_to_sleep_time (3 .1 ) == 0
40- assert c .deadline_to_sleep_time (3.2 ) == 0
41- assert c .deadline_to_sleep_time (4.2 ) == 0.5
39+ assert c .deadline_to_sleep_time (- 0 .1 ) == ( 0 , 0 )
40+ assert c .deadline_to_sleep_time (0.0 ) == ( 0 , 0 )
41+ assert c .deadline_to_sleep_time (1.0 ) == ( 0.5 , 1.0 )
4242
4343 c .rate = 0.5
4444 assert c .current_time () == 3.2
45- assert c .deadline_to_sleep_time (3 .1 ) == 0
46- assert c .deadline_to_sleep_time (3.2 ) == 0
47- assert c .deadline_to_sleep_time (4.2 ) == 2.0
45+ assert c .deadline_to_sleep_time (- 0 .1 ) == ( 0 , 0 )
46+ assert c .deadline_to_sleep_time (0.0 ) == ( 0 , 0 )
47+ assert c .deadline_to_sleep_time (1.0 ) == ( 2.0 , 1.0 )
4848
4949 c .jump (0.8 )
5050 assert c .current_time () == 4.0
@@ -80,11 +80,12 @@ async def test_mock_clock_autojump(mock_clock: MockClock) -> None:
8080 t = _core .current_time ()
8181 # this should wake up before the autojump threshold triggers, so time
8282 # shouldn't change
83+ # TODO: technically, this waits for an infinite virtual time - how should `current_time()` change?
8384 await wait_all_tasks_blocked ()
8485 assert t == _core .current_time ()
8586 # this should too
8687 await wait_all_tasks_blocked (0.01 )
87- assert t == _core .current_time ()
88+ assert t + 0.01 == _core .current_time ()
8889
8990 # set up a situation where the autojump task is blocked for a long long
9091 # time, to make sure that cancel-and-adjust-threshold logic is working
@@ -179,15 +180,16 @@ async def waiter() -> None:
179180
180181
181182async def test_initialization_doesnt_mutate_runner () -> None :
183+ # TODO: is this test even necessary now?
182184 before = (
183185 GLOBAL_RUN_CONTEXT .runner .clock ,
184- GLOBAL_RUN_CONTEXT .runner .clock .autojump_threshold ,
186+ # GLOBAL_RUN_CONTEXT.runner.clock.autojump_threshold,
185187 )
186188
187189 MockClock (autojump_threshold = 2 , rate = 3 )
188190
189191 after = (
190192 GLOBAL_RUN_CONTEXT .runner .clock ,
191- GLOBAL_RUN_CONTEXT .runner .clock .autojump_threshold ,
193+ # GLOBAL_RUN_CONTEXT.runner.clock.autojump_threshold,
192194 )
193195 assert before == after
0 commit comments