File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 1+ """
2+ Collection of unit tests for the ProgressDisplay logger.
3+ """
4+
5+ import pytest
6+
7+ from pyalicevision .system import ConsoleProgressDisplay
8+
9+
10+ PROGRESS_BAR_TEMPLATE = """{desc}
11+ 0% 10 20 30 40 50 60 70 80 90 100%
12+ |----|----|----|----|----|----|----|----|----|----|
13+ """
14+
15+ def test_progress_display (capfd ):
16+ items = range (10 )
17+ desc = "Iter over items"
18+ stars_by_item = "*" * (50 // len (items ))
19+ progress = ConsoleProgressDisplay (len (items ), desc + "\n " )
20+ for index , _i in enumerate (items ):
21+ assert (progress .count () == index )
22+ out , _ = capfd .readouterr () # readout is flushed each time we call this so we only have to check for diff
23+ if index == 0 :
24+ assert out == PROGRESS_BAR_TEMPLATE .format (desc = desc )
25+ else :
26+ assert out == stars_by_item
27+ progress += 1
You can’t perform that action at this time.
0 commit comments