Files
cibuildwheel/unit_test/wheel_print_test.py
T
Henry Schreiner 7ef593c2ad fix: minor touchups based on stricter mypy settings (#1060)
* fix: minor touchups based on stricter mypy settings

* refactor: address review comments
2022-04-01 22:00:07 -04:00

36 lines
1.1 KiB
Python

import pytest
from cibuildwheel.util import print_new_wheels
def test_printout_wheels(tmp_path, capsys):
tmp_path.joinpath("example.0").touch()
with print_new_wheels("TEST_MSG: {n}", tmp_path):
tmp_path.joinpath("example.1").write_bytes(b"0" * 1023)
tmp_path.joinpath("example.2").write_bytes(b"0" * 1025)
captured = capsys.readouterr()
assert captured.err == ""
assert "example.0" not in captured.out
assert "example.1 1 kB\n" in captured.out
assert "example.2 2 kB\n" in captured.out
assert "TEST_MSG:" in captured.out
assert "TEST_MSG: 2\n" in captured.out
def test_no_printout_on_error(tmp_path, capsys):
tmp_path.joinpath("example.0").touch()
with pytest.raises(RuntimeError):
with print_new_wheels("TEST_MSG: {n}", tmp_path):
tmp_path.joinpath("example.1").touch()
raise RuntimeError()
captured = capsys.readouterr() # type: ignore[unreachable]
assert captured.err == ""
assert "example.0" not in captured.out
assert "example.1" not in captured.out
assert "example.2" not in captured.out
assert "TEST_MSG:" not in captured.out