Skip to content

Commit 49829a7

Browse files
committed
fix: fixup tests and formatting
Signed-off-by: Henry Schreiner <[email protected]>
1 parent db6b675 commit 49829a7

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

cibuildwheel/logger.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import codecs
2+
import functools
3+
import io
24
import os
35
import re
46
import sys
@@ -197,20 +199,24 @@ def error(self, error: BaseException | str) -> None:
197199
print(f"cibuildwheel: {c.bright_red}error{c.end}: {error}\n", file=sys.stderr)
198200

199201
def print_summary(self) -> None:
200-
summary = "## 🎡: Wheels\n\n| Identifier | Wheel | Size | Time |\n|===|===|===|===|\n"
202+
string_io = io.StringIO()
203+
ioprint = functools.partial(print, file=string_io)
204+
ioprint("## 🎡: Wheels\n")
205+
ioprint("| Identifier | Wheel | Size | Time |")
206+
ioprint("|===|===|===|===|")
201207
for ident, filename, duration in self.summary:
202208
if filename:
203209
size_mb = filename.stat().st_size / 1024**2
204-
summary += f"| {ident} | {filename.name} | {size_mb:.2f} MB | {duration} |"
210+
ioprint(f"| {ident} | {filename.name} | {size_mb:.2f} MB | {duration} |")
205211
else:
206-
summary += f"| {ident} | test only | --- | {duration} |"
212+
ioprint(f"| {ident} | test only | --- | {duration} |")
207213

208-
match self.summary_mode:
209-
case "github":
210-
Path(os.environ["GITHUB_STEP_SUMMARY"]).write_text(summary, encoding="utf-8")
211-
print(summary)
212-
case _:
213-
print(summary)
214+
if self.summary_mode == "github":
215+
Path(os.environ["GITHUB_STEP_SUMMARY"]).write_text(
216+
string_io.getvalue(), encoding="utf-8"
217+
)
218+
219+
print(string_io.getvalue())
214220

215221
self.summary = []
216222

unit_test/wheel_print_test.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ def test_printout_wheels(tmp_path, capsys):
1212
captured = capsys.readouterr()
1313
assert captured.err == ""
1414

15-
assert "example.0" not in captured.out
16-
assert "example.1 1 kB\n" in captured.out
17-
assert "example.2 2 kB\n" in captured.out
1815
assert "TEST_MSG:" in captured.out
1916
assert "TEST_MSG: 2\n" in captured.out
2017

@@ -28,7 +25,4 @@ def test_no_printout_on_error(tmp_path, capsys):
2825
captured = capsys.readouterr()
2926
assert captured.err == ""
3027

31-
assert "example.0" not in captured.out
32-
assert "example.1" not in captured.out
33-
assert "example.2" not in captured.out
3428
assert "TEST_MSG:" not in captured.out

0 commit comments

Comments
 (0)