File: test_progress_display.py

package info (click to toggle)
alicevision 3.3.1%2Brepack-3
  • links: PTS, VCS
  • area: contrib
  • in suites: sid
  • size: 34,232 kB
  • sloc: cpp: 142,191; python: 13,724; ansic: 7,937; modula3: 6,977; sh: 163; makefile: 66
file content (27 lines) | stat: -rw-r--r-- 839 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""
Collection of unit tests for the ProgressDisplay logger.
"""

import pytest

from pyalicevision.system import ConsoleProgressDisplay


PROGRESS_BAR_TEMPLATE = """{desc}
0%   10   20   30   40   50   60   70   80   90   100%
|----|----|----|----|----|----|----|----|----|----|
"""

def test_progress_display(capfd):
    items = range(10)
    desc = "Iter over items"
    stars_by_item = "*" * (50 // len(items))
    progress = ConsoleProgressDisplay(len(items), desc + "\n")
    for index, _i in enumerate(items):
        assert(progress.count() == index)
        out, _ = capfd.readouterr()  # readout is flushed each time we call this so we only have to check for diff
        if index == 0:
            assert out == PROGRESS_BAR_TEMPLATE.format(desc=desc)
        else:
            assert out == stars_by_item
        progress += 1