MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_capsysbinary

Method test_capsysbinary

testing/test_capture.py:549–583  ·  view source on GitHub ↗
(self, pytester: Pytester)

Source from the content-addressed store, hash-verified

547 reprec.assertoutcome(passed=1)
548
549 def test_capsysbinary(self, pytester: Pytester) -> None:
550 p1 = pytester.makepyfile(
551 r"""
552 def test_hello(capsysbinary):
553 import sys
554
555 sys.stdout.buffer.write(b'hello')
556
557 # Some likely un-decodable bytes.
558 sys.stdout.buffer.write(b'\xfe\x98\x20')
559
560 sys.stdout.buffer.flush()
561
562 # Ensure writing in text mode still works and is captured.
563 # https://github.com/pytest-dev/pytest/issues/6871
564 print("world", flush=True)
565
566 out, err = capsysbinary.readouterr()
567 assert out == b'hello\xfe\x98\x20world\n'
568 assert err == b''
569
570 print("stdout after")
571 print("stderr after", file=sys.stderr)
572 """
573 )
574 result = pytester.runpytest(str(p1), "-rA")
575 result.stdout.fnmatch_lines(
576 [
577 "*- Captured stdout call -*",
578 "stdout after",
579 "*- Captured stderr call -*",
580 "stderr after",
581 "*= 1 passed in *",
582 ]
583 )
584
585 def test_partial_setup_failure(self, pytester: Pytester) -> None:
586 p = pytester.makepyfile(

Callers

nothing calls this directly

Calls 3

fnmatch_linesMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected