def test_show_progress_win32(capsys, monkeypatch, terminal_size): """ Check that we show a crippled progress bar on Windows. """ monkeypatch.setattr(sys, 'platform', 'win32') monkeypatch.setattr(sys.stderr, 'isatty', lambda: True) assert not is_progressbar_capable() assert_show_no_progressbar(capsys)
def test_show_progress_no_tty(capsys, monkeypatch, terminal_size): """ Check that we show a crippled progress bar when stderr is not a terminal. """ monkeypatch.setattr(sys, 'platform', 'notwin32') monkeypatch.setattr(sys.stderr, 'isatty', lambda: False) assert not is_progressbar_capable() assert_show_no_progressbar(capsys)
def test_show_progress(capsys, monkeypatch, terminal_size): """ Set the necessary conditions and check that we can write a progress bar to stderr. """ monkeypatch.setattr(sys, 'platform', 'notwin32') monkeypatch.setattr(sys.stderr, 'isatty', lambda: True) assert is_progressbar_capable() assert_show_progressbar(capsys)
def test_no_progress_quiet(capsys, monkeypatch, terminal_size): """ Check that nothing is printed when the global "quiet" option is set. """ monkeypatch.setattr(sys, 'platform', 'notwin32') monkeypatch.setattr(sys.stderr, 'isatty', lambda: True) assert is_progressbar_capable() monkeypatch.setitem(launch_jenkins.CONFIG, 'quiet', True) assert_show_empty_progress(capsys)
def test_show_progress_no_get_size(capsys, monkeypatch): """ Check that we show a crippled progress bar when we can't get the terminal size. """ monkeypatch.setattr(sys, 'platform', 'notwin32') monkeypatch.setattr(sys.stderr, 'isatty', lambda: True) monkeypatch.setattr(launch_jenkins, 'get_stderr_size_unix', raise_error) assert not is_progressbar_capable() assert_show_no_progressbar(capsys)
def test_show_progress_force(capsys, monkeypatch, terminal_size): """ Check that we can force the progress bar to be shown, even if the terminal is not technically capable. """ # Force progress through config monkeypatch.setitem(launch_jenkins.CONFIG, 'progress', True) # Set all the right conditions monkeypatch.setattr(sys, 'platform', 'notwin32') monkeypatch.setattr(sys.stderr, 'isatty', lambda: True) # Cripple conditions one by one with monkeypatch.context(): monkeypatch.setattr(sys, 'platform', 'win32') assert is_progressbar_capable() with monkeypatch.context(): monkeypatch.setattr(sys.stderr, 'isatty', lambda: False) assert is_progressbar_capable() with monkeypatch.context(): # Even force is set, we can't progress bar without stderr size monkeypatch.setattr(launch_jenkins, 'get_stderr_size_unix', raise_error) assert not is_progressbar_capable()