From d19223de8f62690a580b163117dda6fe97350d0f Mon Sep 17 00:00:00 2001 From: henrykironde Date: Tue, 7 Jan 2025 15:00:57 -0500 Subject: [PATCH] Tests both verbose=False and verbose=True in single tests --- tests/test_main.py | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index d7773262..b4103dd9 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -322,24 +322,35 @@ def test_predict_tile_no_mosaic(m, raster_path): assert len(prediction[0]) == 2 assert prediction[0][1].shape == (300, 300, 3) -def test_predict_tile_verbose(m, raster_path, capsys, verbose=False): +def test_predict_tile_verbose(m, raster_path, capsys): + """Test that verbose output can be controlled in predict_tile""" + # Test with verbose=False m.config["train"]["fast_dev_run"] = False m.create_trainer() - prediction = m.predict_tile(raster_path=raster_path, - patch_size=300, - patch_overlap=0, - mosaic=True, - verbose=verbose) - + prediction = m.predict_tile( + raster_path=raster_path, + patch_size=300, + patch_overlap=0, + mosaic=True, + verbose=False + ) + # Check no output was printed - if not verbose: - captured = capsys.readouterr() - print(captured.out) - assert not captured.out - else: - captured = capsys.readouterr() - print(captured.out) - assert captured.out + captured = capsys.readouterr() + assert not captured.out.strip() + + # Test with verbose=True + prediction = m.predict_tile( + raster_path=raster_path, + patch_size=300, + patch_overlap=0, + mosaic=True, + verbose=True + ) + + # Check output was printed + captured = capsys.readouterr() + assert captured.out.strip() def test_evaluate(m, tmpdir): csv_file = get_data("OSBS_029.csv")