11import contextlib
22import re
3+ import time
34import typing
45from unittest import mock
56
@@ -25,9 +26,7 @@ def __init__(self):
2526 @contextlib .contextmanager
2627 def patch (self , time_machine : time_machine .TimeMachineFixture ) -> typing .Iterator ["_Sleeper" ]:
2728 def sleep (seconds ):
28- # Note: this requires that `time_machine.move_to()` has been called before
29- # also see https://github.com/adamchainz/time-machine/issues/247
30- time_machine .coordinates .shift (seconds )
29+ time_machine .shift (seconds )
3130 self .history .append (seconds )
3231
3332 with mock .patch ("time.sleep" , new = sleep ):
@@ -58,15 +57,15 @@ def oidc_device_code_flow_checker(time_machine, simple_time, fast_sleep, capsys)
5857
5958 @contextlib .contextmanager
6059 def assert_oidc_device_code_flow (url : str = "https://oidc.test/dc" , elapsed : float = 3 , check_capsys : bool = True ):
61- start = time_machine . coordinates .time ()
60+ start = time .time ()
6261 yield
6362 assert fast_sleep .did_sleep ()
6463 if check_capsys :
6564 stdout , _ = capsys .readouterr ()
6665 assert f"Visit { url } and enter" in stdout
6766 assert re .search (r"\[#+-*\] Authorization pending *\r\[#+-*\] Polling *\r" , stdout )
6867 assert re .search (r"Authorized successfully *\r\n" , stdout )
69- assert time_machine . coordinates .time () - start >= elapsed
68+ assert time .time () - start >= elapsed
7069
7170 return assert_oidc_device_code_flow
7271
0 commit comments