Files
cibuildwheel/unit_test/wheel_print_test.py
Henry Schreinerandpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> 097806b6b1 tests: fully type the test suite (#2794)
* tests: fully type the test suite

* chore: require more typing

Signed-off-by: Henry Schreiner <henryfs@princeton.edu>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-04-01 15:23:02 +01:00

43 lines
1.3 KiB
Python

from pathlib import Path
import pytest
from cibuildwheel.logger import BuildInfo, Logger
from cibuildwheel.options import CommandLineArguments, Options
OPTIONS_DEFAULTS = Options("linux", CommandLineArguments.defaults(), {}, defaults=True)
FILE = Path(__file__)
def test_printout_wheels(capsys: pytest.CaptureFixture[str]) -> None:
log = Logger()
log.fold_mode = "disabled"
log.colors_enabled = False
with log.print_summary(options=OPTIONS_DEFAULTS):
# the number of BuildInfo with & without filename shall be different for this test
log.summary = [
BuildInfo(identifier="id1", filename=None, duration=3),
BuildInfo(identifier="id2", filename=FILE, duration=2),
BuildInfo(identifier="id3", filename=FILE, duration=3),
]
captured = capsys.readouterr()
assert captured.err == ""
assert "id1" in captured.out
assert "id2" in captured.out
assert "id3" in captured.out
assert "2 wheels produced in" in captured.out
assert "SHA256=" in captured.out
def test_no_printout_on_error(capsys: pytest.CaptureFixture[str]) -> None:
log = Logger()
with pytest.raises(RuntimeError), log.print_summary(options=OPTIONS_DEFAULTS):
raise RuntimeError()
captured = capsys.readouterr()
assert captured.err == ""
assert captured.out == ""