Skip to content

Commit

Permalink
tests: add test for preserving newlines with capsys/capfd (#401)
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed committed Jul 22, 2020
1 parent b529a1a commit 33f4c62
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions testing/test_capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
from _pytest.capture import _get_multicapture
from _pytest.capture import CaptureManager
from _pytest.capture import MultiCapture
from _pytest.compat import TYPE_CHECKING
from _pytest.config import ExitCode

if TYPE_CHECKING:
from _pytest.fixtures import FixtureRequest

# note: py.io capture tests where copied from
# pylib 1.4.20.dev2 (rev 13d9af95547e)

Expand Down Expand Up @@ -526,6 +530,16 @@ def test_hello(capfd):
)
reprec.assertoutcome(passed=1)

@pytest.mark.parametrize("fixturename", ("capfd", "capsys"))
def test_preserves_newlines(
self, fixturename: str, request: "FixtureRequest"
) -> None:
fixture = request.getfixturevalue(fixturename)
output = "test1\rtest2\ntest3\r\ntest4"
print(output, end="")
out, err = fixture.readouterr()
assert out == output

@needsosdup
def test_capfdbinary(self, testdir):
reprec = testdir.inline_runsource(
Expand Down

0 comments on commit 33f4c62

Please sign in to comment.