Skip to content

Commit abb5d20

Browse files
committed
Merge branch 'master' into features
2 parents 9e3e58a + da12c52 commit abb5d20

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

AUTHORS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ Kevin Cox
9393
Kodi B. Arfer
9494
Lee Kamentsky
9595
Lev Maximov
96+
Llandy Riveron Del Risco
9697
Loic Esteve
9798
Lukas Bednar
9899
Luke Murphy
@@ -168,3 +169,4 @@ Vitaly Lashmanov
168169
Vlad Dragos
169170
Wouter van Ackooy
170171
Xuecong Liao
172+
Zoltán Máté

_pytest/compat.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,15 @@ def _setup_collect_fakemodule():
282282

283283

284284
if _PY2:
285-
from py.io import TextIO as CaptureIO
285+
# Without this the test_dupfile_on_textio will fail, otherwise CaptureIO could directly inherit from StringIO.
286+
from py.io import TextIO
287+
288+
class CaptureIO(TextIO):
289+
290+
@property
291+
def encoding(self):
292+
return getattr(self, '_encoding', 'UTF-8')
293+
286294
else:
287295
import io
288296

changelog/2375.trivial

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Provides encoding attribute on CaptureIO.

testing/test_capture.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ def test_something():
355355
""")
356356
result = testdir.runpytest_subprocess(
357357
p, "--traceconfig",
358-
"-p", "no:capturelog")
358+
"-p", "no:capturelog", "-p", "no:hypothesis", "-p", "no:hypothesispytest")
359359
assert result.ret != 0
360360
result.stdout.fnmatch_lines([
361361
"*hello432*",
@@ -1040,6 +1040,15 @@ def test_capture_not_started_but_reset():
10401040
capsys.stop_capturing()
10411041

10421042

1043+
def test_using_capsys_fixture_works_with_sys_stdout_encoding(capsys):
1044+
test_text = 'test text'
1045+
1046+
print(test_text.encode(sys.stdout.encoding, 'replace'))
1047+
(out, err) = capsys.readouterr()
1048+
assert out
1049+
assert err == ''
1050+
1051+
10431052
@needsosdup
10441053
@pytest.mark.parametrize('use', [True, False])
10451054
def test_fdcapture_tmpfile_remains_the_same(tmpfile, use):

0 commit comments

Comments
 (0)