Skip to content

Commit

Permalink
tests: fix command outputs includes \r\n on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Jan 30, 2020
1 parent 8008a17 commit 78cfb0c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from covimerage import DEFAULT_COVERAGE_DATA_FILE, cli, get_version
from covimerage.cli import get_version_message

NEWLINE = '\n' if sys.platform != 'win32' else '\r\n'


def test_dunder_main_run(capfd):
assert call([sys.executable, '-m', 'covimerage']) == 0
Expand Down Expand Up @@ -293,7 +295,7 @@ def test_cli_run_report_fd(capfd, tmpdir, devnull):
def test_cli_call(capfd):
assert call(['covimerage', '--version']) == 0
out, err = capfd.readouterr()
assert out == get_version_message() + '\n'
assert out == get_version_message() + NEWLINE

assert call(['covimerage', '--help']) == 0
out, err = capfd.readouterr()
Expand Down Expand Up @@ -354,7 +356,7 @@ def test_cli_call_verbosity_fd(capfd):
assert call(['covimerage', '-qq', 'write_coverage', os.devnull]) == 1
out, err = capfd.readouterr()
assert out == ''
assert err == 'Error: No data to report.\n'
assert err == 'Error: No data to report.' + NEWLINE


def test_cli_writecoverage_without_data(runner):
Expand Down Expand Up @@ -662,7 +664,7 @@ def test_run_handles_exit_code_from_python_fd(capfd):
'python', '-c', 'print("output"); import sys; sys.exit(42)'])
out, err = capfd.readouterr()
assert 'Error: Command exited non-zero: 42.' in err.splitlines()
assert out == 'output\n'
assert out == 'output' + NEWLINE
assert ret == 42


Expand Down

0 comments on commit 78cfb0c

Please sign in to comment.