diff options
author | David Robertson <davidr@element.io> | 2022-06-11 18:33:07 +0100 |
---|---|---|
committer | David Robertson <davidr@element.io> | 2022-06-11 18:33:53 +0100 |
commit | a07c7335cc1023e2872a5fb1049385b52cc9581f (patch) | |
tree | dd1c3501db7de7c1fb77b80a7db3503f8dae7608 | |
parent | Annotate `default_config` (diff) | |
download | synapse-a07c7335cc1023e2872a5fb1049385b52cc9581f.tar.xz |
Track `now` as a float
`time_ms` returns an int like the proper Synapse `Clock`
-rw-r--r-- | tests/utils.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/tests/utils.py b/tests/utils.py index 6a66a938a7..cae851a0eb 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -219,7 +219,7 @@ def mock_getRawHeaders(headers=None): class MockClock: - now = 1000 + now = 1000.0 def __init__(self) -> None: # list of lists of [absolute_time, callback, expired] in no particular @@ -227,11 +227,11 @@ class MockClock: self.timers = [] self.loopers = [] - def time(self): + def time(self) -> float: return self.now - def time_msec(self): - return self.time() * 1000 + def time_msec(self) -> int: + return int(self.time() * 1000) def call_later(self, delay, callback, *args, **kwargs): ctx = current_context() @@ -257,7 +257,7 @@ class MockClock: self.timers = [t for t in self.timers if t != timer] # For unit testing - def advance_time(self, secs): + def advance_time(self, secs: float) -> None: self.now += secs timers = self.timers @@ -281,7 +281,7 @@ class MockClock: func(*args, **kwargs) looped[2] = self.now - def advance_time_msec(self, ms): + def advance_time_msec(self, ms: float) -> None: self.advance_time(ms / 1000.0) |