From 0eebeb9900eea9117c78922b04b4e46cb7df3009 Mon Sep 17 00:00:00 2001 From: skshetry <18718008+skshetry@users.noreply.github.com> Date: Wed, 7 May 2025 12:40:51 +0545 Subject: [PATCH] tests: fix flaky test in test_get_used_objs (#10739) Clear logs before assertions so that logs from other tests do not interfere with the test. Some destructors may also run in between due to GC, so hopefully this will fix that issue too, or reduce the chances of it happening. See https://github.com/iterative/dvc/actions/runs/14873217814/job/41775314725#step:6:97. ```console > assert first(caplog.messages) == expected_message E assert 'RC: discarding all clients' == "Output 'path... 'stage.dvc'." E E + RC: discarding all clients E - Output 'path'(stage: 'stage.dvc') is missing version info. Cache for it will not be collected. Use `dvc repro` to get your pipeline up to date. E - You can also use `dvc commit stage.dvc` to associate existing 'path' with stage: 'stage.dvc'. ``` --- tests/unit/output/test_output.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/output/test_output.py b/tests/unit/output/test_output.py index 8adb66fca..bf86b88b2 100644 --- a/tests/unit/output/test_output.py +++ b/tests/unit/output/test_output.py @@ -101,6 +101,7 @@ def test_get_used_objs(exists, expected_message, mocker, caplog): Output, "exists", new_callable=mocker.PropertyMock ).return_value = exists + caplog.clear() with caplog.at_level(logging.WARNING, logger="dvc"): assert output.get_used_objs() == {} assert first(caplog.messages) == expected_message