Skip to content

Commit 7253464

Browse files
authored
#1223 resolve unicode spinner error (#1225)
1 parent b5105b1 commit 7253464

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

docs/changelog/1223.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Spinner fails in CI on ``UnicodeDecodeError`` - by :user:`gaborbernat`

src/tox/util/spinner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def _file_support_encoding(chars, file):
2525
for char in chars:
2626
try:
2727
char.encode(encoding)
28-
except UnicodeDecodeError:
28+
except UnicodeEncodeError:
2929
break
3030
else:
3131
return True

tests/unit/util/test_spinner.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,13 @@ def test_spinner_long_text(capfd, monkeypatch):
9696
lines = out.split("\n")
9797
del lines[0]
9898
assert lines == expected
99+
100+
101+
def test_spinner_stdout_not_unicode(capfd, monkeypatch):
102+
monkeypatch.setattr(sys.stdout, "encoding", "ascii")
103+
with spinner.Spinner(refresh_rate=100) as spin:
104+
for _ in range(len(spin.frames)):
105+
spin.render_frame()
106+
out, err = capfd.readouterr()
107+
assert not err
108+
assert all(f in out for f in spin.frames)

0 commit comments

Comments
 (0)