mirror of
https://github.com/bckelley/tconnectsync.git
synced 2026-08-24 03:34:12 -05:00
Fix flaky autoupdate tests: use constant mocked clock
Patching autoupdate.time.time patches the global time.time, which logging calls internally per record; a finite side_effect list gets exhausted and raises StopIteration on Python 3.11. Use return_value. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
4bae860212
commit
c95fe424ab
@@ -719,7 +719,7 @@ class TestTandemSourceAutoupdate(unittest.TestCase):
|
||||
|
||||
with mock.patch('tconnectsync.sync.tandemsource.autoupdate.ChooseDevice', FakeChooseDevice), \
|
||||
mock.patch('tconnectsync.sync.tandemsource.autoupdate.ProcessTimeRange', FakeProcessTimeRange), \
|
||||
mock.patch('tconnectsync.sync.tandemsource.autoupdate.time.time', side_effect=[1000, 1001, 1002]), \
|
||||
mock.patch('tconnectsync.sync.tandemsource.autoupdate.time.time', return_value=1000), \
|
||||
mock.patch('tconnectsync.sync.tandemsource.autoupdate.time.sleep', return_value=None), \
|
||||
self.assertLogs('tconnectsync.sync.tandemsource.autoupdate', level='INFO') as logs:
|
||||
result = autoupdate.process(object(), object(), pretend=False)
|
||||
@@ -731,7 +731,7 @@ class TestTandemSourceAutoupdate(unittest.TestCase):
|
||||
autoupdate = TandemSourceAutoupdate(self.secret)
|
||||
|
||||
with mock.patch('tconnectsync.sync.tandemsource.autoupdate.ChooseDevice', FakeChooseDevice), \
|
||||
mock.patch('tconnectsync.sync.tandemsource.autoupdate.time.time', side_effect=[2000, 2001, 2002]), \
|
||||
mock.patch('tconnectsync.sync.tandemsource.autoupdate.time.time', return_value=2000), \
|
||||
mock.patch('tconnectsync.sync.tandemsource.autoupdate.time.sleep', return_value=None), \
|
||||
self.assertLogs('tconnectsync.sync.tandemsource.autoupdate', level='INFO') as logs:
|
||||
result = autoupdate.process(object(), object(), pretend=True)
|
||||
|
||||
Reference in New Issue
Block a user