@@ -1536,21 +1536,39 @@ def test_capture({0}):
1536
1536
assert result .ret == 0
1537
1537
1538
1538
1539
+ @pytest .mark .pypy_specific
1539
1540
def test_typeerror_encodedfile_write (testdir ):
1540
- """It should behave the same with and without output capturing (#4861)."""
1541
+ """It should behave the same with and without output capturing (#4861).
1542
+
1543
+ The reported location differs however.
1544
+ """
1541
1545
p = testdir .makepyfile (
1542
1546
"""
1543
1547
def test_fails():
1544
1548
import sys
1545
1549
sys.stdout.write(b"foo")
1546
1550
"""
1547
1551
)
1548
- result_without_capture = testdir .runpytest ("-s" , str (p ))
1549
1552
result_with_capture = testdir .runpytest (str (p ))
1550
-
1551
- assert result_with_capture .ret == result_without_capture .ret
1552
1553
result_with_capture .stdout .fnmatch_lines (
1553
- ["E * TypeError: write() argument must be str, not bytes" ]
1554
+ [
1555
+ '> sys.stdout.write(b"foo")' ,
1556
+ " def write*" ,
1557
+ "E TypeError: write() argument must be str, not bytes" ,
1558
+ "FAILED test_typeerror_encodedfile_write.py:3::test_fails - *" ,
1559
+ ]
1560
+ )
1561
+ result_without_capture = testdir .runpytest ("-s" , str (p ))
1562
+ if getattr (sys , "pypy_version_info" , None ):
1563
+ exp_exc = "TypeError: unicode argument expected, got 'bytes'"
1564
+ else :
1565
+ exp_exc = "TypeError: write() argument must be str, not bytes"
1566
+ result_without_capture .stdout .fnmatch_lines (
1567
+ [
1568
+ '> sys.stdout.write(b"foo")' ,
1569
+ "E " + exp_exc ,
1570
+ "FAILED test_typeerror_encodedfile_write.py:3::test_fails - *" ,
1571
+ ]
1554
1572
)
1555
1573
1556
1574
0 commit comments