Skip to content

Commit

Permalink
Python: Add test using tqdm progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
dbaston committed Jul 26, 2024
1 parent f124c77 commit 38ea8a5
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions python/tests/test_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,30 @@ def status(frac, message):
assert len(fracs) == len(square_features)
assert fracs == sorted(fracs)
assert fracs[-1] == 1.0


def test_progress_tqdm(np_raster_source, square_features):
tqdm = pytest.importorskip("tqdm")

ops = [
Operation("count", "count", np_raster_source),
]
writer = JSONWriter()

fs = JSONFeatureSource(square_features * 100)

bar = tqdm.tqdm(total=100)

def status(frac, message):
pct = frac * 100
bar.update(pct - bar.n)
if pct == 100:
bar.close()

processor = FeatureSequentialProcessor(fs, writer, ops)
processor.set_progress_fn(status)
processor.show_progress(True)

assert bar.n == 0
processor.process()
assert bar.n == 100

0 comments on commit 38ea8a5

Please sign in to comment.