feat: print new files after building (#570)

This commit is contained in:
Henry Schreiner
2021-02-04 14:27:54 -05:00
committed by GitHub
parent 08401d6608
commit e12ce2d647
4 changed files with 78 additions and 9 deletions
+10
View File
@@ -1,3 +1,4 @@
import contextlib
import platform as platform_module
import subprocess
import sys
@@ -58,6 +59,15 @@ def fake_package_dir(monkeypatch):
return args
@pytest.fixture(autouse=True)
def disable_print_wheels(monkeypatch):
@contextlib.contextmanager
def empty_cm(*args, **kwargs):
yield
monkeypatch.setattr(util, 'print_new_wheels', empty_cm)
@pytest.fixture
def allow_empty(request, monkeypatch, fake_package_dir):
monkeypatch.setattr(sys, 'argv', fake_package_dir + ['--allow-empty'])
+35
View File
@@ -0,0 +1,35 @@
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").touch()
tmp_path.joinpath("example.2").touch()
captured = capsys.readouterr()
assert captured.err == ""
assert "example.0" not in captured.out
assert "example.1\n" in captured.out
assert "example.2\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()
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