Files
cibuildwheel/unit_test/wheel_print_test.py
T

35 lines
1.1 KiB
Python
Raw Normal View History

2021-02-04 14:27:54 -05:00
import pytest
2025-01-27 20:35:56 +01:00
from cibuildwheel.__main__ import print_new_wheels
2021-02-04 14:27:54 -05:00
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)
2021-02-04 14:27:54 -05:00
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
2021-02-04 14:27:54 -05:00
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()
2023-01-30 15:53:44 -05:00
with pytest.raises(RuntimeError), print_new_wheels("TEST_MSG: {n}", tmp_path): # noqa: PT012
tmp_path.joinpath("example.1").touch()
raise RuntimeError()
2021-02-04 14:27:54 -05:00
2024-10-22 10:16:59 -04:00
captured = capsys.readouterr()
2021-02-04 14:27:54 -05:00
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