Preserve newlines when captured with capfd
This commit is contained in:
parent
41d211c24a
commit
8616a5f1d9
|
@ -0,0 +1 @@
|
|||
Preserve line endings when captured via ``capfd``.
|
|
@ -388,6 +388,7 @@ class FDCaptureBinary:
|
|||
TemporaryFile(buffering=0), # type: ignore[arg-type]
|
||||
encoding="utf-8",
|
||||
errors="replace",
|
||||
newline="",
|
||||
write_through=True,
|
||||
)
|
||||
if targetfd in patchsysdict:
|
||||
|
|
|
@ -514,6 +514,12 @@ class TestCaptureFixture:
|
|||
)
|
||||
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):
|
||||
reprec = testdir.inline_runsource(
|
||||
"""\
|
||||
|
|
Loading…
Reference in New Issue