From c95fe424ab7da6db65997a9d2784e8037f9ebe12 Mon Sep 17 00:00:00 2001 From: James Woglom Date: Mon, 20 Jul 2026 20:46:23 -0400 Subject: [PATCH] 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 --- tests/sync/tandemsource/test_autoupdate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/sync/tandemsource/test_autoupdate.py b/tests/sync/tandemsource/test_autoupdate.py index dcd1804..a9e7caf 100644 --- a/tests/sync/tandemsource/test_autoupdate.py +++ b/tests/sync/tandemsource/test_autoupdate.py @@ -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)