@@ -1533,20 +1533,35 @@ def test_capture({0}):
1533
1533
1534
1534
1535
1535
def test_typeerror_encodedfile_write (testdir ):
1536
- """It should behave the same with and without output capturing (#4861)."""
1536
+ """It should behave the same with and without output capturing (#4861).
1537
+
1538
+ The reported location differs however.
1539
+ """
1537
1540
p = testdir .makepyfile (
1538
1541
"""
1539
1542
def test_fails():
1540
1543
import sys
1541
1544
sys.stdout.write(b"foo")
1542
1545
"""
1543
1546
)
1544
- result_without_capture = testdir .runpytest ("-s" , str (p ))
1545
1547
result_with_capture = testdir .runpytest (str (p ))
1546
-
1547
- assert result_with_capture .ret == result_without_capture .ret
1548
1548
result_with_capture .stdout .fnmatch_lines (
1549
- ["E * TypeError: write() argument must be str, not bytes" ]
1549
+ [
1550
+ '> sys.stdout.write(b"foo")' ,
1551
+ "> raise TypeError*" ,
1552
+ "E TypeError: write() argument must be str, not bytes" ,
1553
+ "FAILED test_typeerror_encodedfile_write.py:3::test_fails"
1554
+ " - TypeError: write() argument must be str, not bytes" ,
1555
+ ]
1556
+ )
1557
+ result_without_capture = testdir .runpytest ("-s" , str (p ))
1558
+ result_without_capture .stdout .fnmatch_lines (
1559
+ [
1560
+ '> sys.stdout.write(b"foo")' ,
1561
+ "E TypeError: write() argument must be str, not bytes" ,
1562
+ "FAILED test_typeerror_encodedfile_write.py:3::test_fails"
1563
+ " - TypeError: write() argument must be str, not bytes" ,
1564
+ ]
1550
1565
)
1551
1566
1552
1567
0 commit comments