Merge pull request #7521 from asottile/newlines_unaffected
Preserve newlines when captured with capfd
This commit is contained in:
commit
6ecb8f53d0
|
@ -0,0 +1 @@
|
||||||
|
Preserve line endings when captured via ``capfd``.
|
|
@ -388,6 +388,7 @@ class FDCaptureBinary:
|
||||||
TemporaryFile(buffering=0), # type: ignore[arg-type]
|
TemporaryFile(buffering=0), # type: ignore[arg-type]
|
||||||
encoding="utf-8",
|
encoding="utf-8",
|
||||||
errors="replace",
|
errors="replace",
|
||||||
|
newline="",
|
||||||
write_through=True,
|
write_through=True,
|
||||||
)
|
)
|
||||||
if targetfd in patchsysdict:
|
if targetfd in patchsysdict:
|
||||||
|
|
|
@ -514,6 +514,12 @@ class TestCaptureFixture:
|
||||||
)
|
)
|
||||||
reprec.assertoutcome(passed=1)
|
reprec.assertoutcome(passed=1)
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("nl", ("\n", "\r\n", "\r"))
|
||||||
|
def test_cafd_preserves_newlines(self, capfd, nl):
|
||||||
|
print("test", end=nl)
|
||||||
|
out, err = capfd.readouterr()
|
||||||
|
assert out.endswith(nl)
|
||||||
|
|
||||||
def test_capfdbinary(self, testdir):
|
def test_capfdbinary(self, testdir):
|
||||||
reprec = testdir.inline_runsource(
|
reprec = testdir.inline_runsource(
|
||||||
"""\
|
"""\
|
||||||
|
|
Loading…
Reference in New Issue