Skip to content

Commit

Permalink
Add missing fake clock in termui tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bn-jbischko committed May 15, 2018
1 parent 3247cf1 commit d2d80cc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/test_termui.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,31 @@ def __next__(self):

next = __next__

fake_clock = FakeClock()

@click.command()
def cli():
with click.progressbar(Hinted(10), label='test') as progress:
for thing in progress:
time.sleep(.5)
fake_clock.advance_time()

monkeypatch.setattr(time, 'time', fake_clock.time)
monkeypatch.setattr(click._termui_impl, 'isatty', lambda _: True)
result = runner.invoke(cli, [])
assert result.exception is None


def test_progressbar_hidden(runner, monkeypatch):
fake_clock = FakeClock()
label = 'whatever'

@click.command()
def cli():
with click.progressbar(tuple(range(10)), label=label) as progress:
for thing in progress:
pass
fake_clock.advance_time()

monkeypatch.setattr(time, 'time', fake_clock.time)
monkeypatch.setattr(click._termui_impl, 'isatty', lambda _: False)
assert runner.invoke(cli, []).output == ''

Expand Down

0 comments on commit d2d80cc

Please sign in to comment.