MCPcopy
hub / github.com/pytest-dev/pytest / test_libedit_workaround

Function test_libedit_workaround

testing/test_capture.py:1746–1772  ·  view source on GitHub ↗
(pytester: Pytester)

Source from the content-addressed store, hash-verified

1744
1745
1746def test_libedit_workaround(pytester: Pytester) -> None:
1747 pytester.makeconftest("""
1748 import pytest
1749
1750
1751 def pytest_terminal_summary(config):
1752 capture = config.pluginmanager.getplugin("capturemanager")
1753 capture.suspend_global_capture(in_=True)
1754
1755 print("Enter 'hi'")
1756 value = input()
1757 print(f"value: {value!r}")
1758
1759 capture.resume_global_capture()
1760 """)
1761 readline = pytest.importorskip("readline")
1762 backend = getattr(readline, "backend", readline.__doc__) # added in Python 3.13
1763 print(f"Readline backend: {backend}")
1764
1765 child = pytester.spawn_pytest("")
1766 child.expect(r"Enter 'hi'")
1767 child.sendline("hi")
1768 rest = child.read().decode("utf8")
1769 print(rest)
1770 match = re.search(r"^value: '(.*)'\r?$", rest, re.MULTILINE)
1771 assert match is not None
1772 assert match.group(1) == "hi"

Callers

nothing calls this directly

Calls 4

groupMethod · 0.80
makeconftestMethod · 0.45
spawn_pytestMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…