Skip to content

Commit

Permalink
Tests both verbose=False and verbose=True in single tests
Browse files Browse the repository at this point in the history
  • Loading branch information
henrykironde committed Jan 7, 2025
1 parent f4560e6 commit d19223d
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit d19223d

Please sign in to comment.