SIENTIAPDE-1646

Fix flaky shutdown assertions in test suite

GC-collected instances during tests also invoke patched shutdown,
making assert_called_once_with flaky. Count calls for this instance
specifically instead of asserting total call count.
This commit is contained in:
2026-09-25 12:10:18 -03:00
parent 9fb81ef556
commit 5c3c9292fc
3 changed files with 11 additions and 6 deletions

View File

@@ -991,7 +991,8 @@ def test_close_disposes_minio_repository(mock_shutdown):
gates.close()
minio.close.assert_called_once()
assert gates.minio_repository is None
mock_shutdown.assert_called_once_with(gates)
# Other instances collected by GC during the test also hit the patched shutdown.
assert mock_shutdown.call_args_list.count(call(gates)) == 1
@patch.object(SientiaMonitoring, 'shutdown')
@@ -1004,4 +1005,5 @@ def test_close_without_minio_repository(mock_shutdown):
metrics_controller=MagicMock(spec=MetricsController),
)
gates.close()
mock_shutdown.assert_called_once_with(gates)
# Other instances collected by GC during the test also hit the patched shutdown.
assert mock_shutdown.call_args_list.count(call(gates)) == 1