def test_bar_draw(chars, tip, background, percent, end, expected): bar = bar_factory(chars=chars, tip=tip, background=background, borders='||', errors='!x')(10) rendition = bar.end(percent=percent) if end else bar(percent=percent) assert join_cells(rendition) == expected assert len(rendition) == 12 # length + borders
def test_render_title(length, text, expected): local_config = mock.Mock(title=text, title_length=length) assert join_cells(_render_title(local_config)) == expected
def test_unknown_bar(end, expected, spinner_test): bar = bar_factory('a')(10, spinner_factory=spinner_test(('1234567890', ))) method = bar.unknown.end if end else bar.unknown assert join_cells(method()) == expected
def test_alongside_spinner(inputs, expected, spinner_test): spinner_factory = alongside_spinner_factory(*(spinner_test(x) for x in inputs)) spinner = spinner_factory() # natural spinner size. assert tuple(tuple(join_cells(f) for f in spinner()) for _ in expected) == expected
def test_overlay_sliding_window(gap, contents, length, right, initial, expected_6): ribbon = overlay_sliding_window('!@#$%', gap, contents, length, right, initial) assert tuple(join_cells(next(ribbon)) for _ in range(6)) == expected_6
def test_bouncing_spinner(length, block, background, hide, expected): spinner_factory = bouncing_spinner_factory(('abc', 'def'), length, block, background, right=True, hide=hide) spinner = spinner_factory() # natural spinner size. assert tuple(tuple(join_cells(f) for f in spinner()) for _ in expected) == expected
def test_scrolling_spinner(length, block, background, right, hide, expected): spinner_factory = scrolling_spinner_factory('abc', length, block, background, right=right, hide=hide) spinner = spinner_factory() # natural spinner size. assert tuple(tuple(join_cells(f) for f in spinner()) for _ in expected) == expected
def test_frame_spinner(frames, expected): spinner_factory = frame_spinner_factory(frames) spinner = spinner_factory() # natural spinner size. assert tuple(tuple(join_cells(f) for f in spinner()) for _ in expected) == expected
def test_delayed_spinner(copies, offset, expected, spinner_test): spinner_factory = delayed_spinner_factory(spinner_test('12345'), copies, offset) spinner = spinner_factory() # natural spinner size. assert tuple(tuple(join_cells(f) for f in spinner()) for _ in expected) == expected
def test_sequential_spinner_no_intermix(inputs, expected, spinner_test): spinner_factory = sequential_spinner_factory(*(spinner_test(*x) for x in inputs), intermix=False) spinner = spinner_factory() # natural spinner size. assert tuple(tuple(join_cells(f) for f in spinner()) for _ in expected) == expected