src/_pytest/legacypath.py | 4 ++-- src/_pytest/pytester.py | 4 ++-- testing/test_debugging.py | 13 ++++++++----- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/_pytest/legacypath.py b/src/_pytest/legacypath.py index af1d0c07e..c2c78425f 100644 --- a/src/_pytest/legacypath.py +++ b/src/_pytest/legacypath.py @@ -238,12 +238,12 @@ class Testdir: return self._pytester.runpytest_subprocess(*args, timeout=timeout) def spawn_pytest( - self, string: str, expect_timeout: float = 10.0 + self, string: str, expect_timeout: float = 30.0 ) -> "pexpect.spawn": """See :meth:`Pytester.spawn_pytest`.""" return self._pytester.spawn_pytest(string, expect_timeout=expect_timeout) - def spawn(self, cmd: str, expect_timeout: float = 10.0) -> "pexpect.spawn": + def spawn(self, cmd: str, expect_timeout: float = 30.0) -> "pexpect.spawn": """See :meth:`Pytester.spawn`.""" return self._pytester.spawn(cmd, expect_timeout=expect_timeout) diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py index a9299944d..d5790e309 100644 --- a/src/_pytest/pytester.py +++ b/src/_pytest/pytester.py @@ -1511,7 +1511,7 @@ class Pytester: return self.run(*args, timeout=timeout) def spawn_pytest( - self, string: str, expect_timeout: float = 10.0 + self, string: str, expect_timeout: float = 30.0 ) -> "pexpect.spawn": """Run pytest using pexpect. @@ -1526,7 +1526,7 @@ class Pytester: cmd = f"{invoke} --basetemp={basetemp} {string}" return self.spawn(cmd, expect_timeout=expect_timeout) - def spawn(self, cmd: str, expect_timeout: float = 10.0) -> "pexpect.spawn": + def spawn(self, cmd: str, expect_timeout: float = 30.0) -> "pexpect.spawn": """Run a command using pexpect. The pexpect child is returned. diff --git a/testing/test_debugging.py b/testing/test_debugging.py index eecc1e39f..8a23e6559 100644 --- a/testing/test_debugging.py +++ b/testing/test_debugging.py @@ -1,5 +1,6 @@ import os import sys +import time from typing import List import _pytest._code @@ -189,6 +190,8 @@ class TestPDB: child = pytester.spawn_pytest(f"--pdb {p1}") child.expect("Pdb") child.sendline("p self.filename") + # sending the eof after sendline is sometimes ignored + time.sleep(child.delaybeforesend) child.sendeof() rest = child.read().decode("utf8") assert "debug.me" in rest @@ -372,7 +375,7 @@ class TestPDB: result = pytester.runpytest_subprocess("--pdb", ".") result.stdout.fnmatch_lines(["-> import unknown"]) - @pytest.mark.xfail(reason="#10042") + @pytest.mark.xfail(sys.version_info < (3, 8), reason="#10042") def test_pdb_interaction_capturing_simple(self, pytester: Pytester) -> None: p1 = pytester.makepyfile( """ @@ -541,7 +544,7 @@ class TestPDB: assert "BdbQuit" not in rest assert "UNEXPECTED EXCEPTION" not in rest - @pytest.mark.xfail(reason="#10042") + @pytest.mark.xfail(sys.version_info < (3, 8), reason="#10042") def test_pdb_interaction_capturing_twice(self, pytester: Pytester) -> None: p1 = pytester.makepyfile( """ @@ -577,7 +580,7 @@ class TestPDB: assert "1 failed" in rest self.flush(child) - @pytest.mark.xfail(reason="#10042") + @pytest.mark.xfail(sys.version_info < (3, 8), reason="#10042") def test_pdb_with_injected_do_debug(self, pytester: Pytester) -> None: """Simulates pdbpp, which injects Pdb into do_debug, and uses self.__class__ in do_continue. @@ -1022,7 +1025,7 @@ class TestDebuggingBreakpoints: assert "reading from stdin while output" not in rest TestPDB.flush(child) - @pytest.mark.xfail(reason="#10042") + @pytest.mark.xfail(sys.version_info < (3, 8), reason="#10042") def test_pdb_not_altered(self, pytester: Pytester) -> None: p1 = pytester.makepyfile( """ @@ -1182,7 +1185,7 @@ def test_quit_with_swallowed_SystemExit(pytester: Pytester) -> None: @pytest.mark.parametrize("fixture", ("capfd", "capsys")) -@pytest.mark.xfail(reason="#10042") +@pytest.mark.xfail(sys.version_info < (3, 8), reason="#10042") def test_pdb_suspends_fixture_capturing(pytester: Pytester, fixture: str) -> None: """Using "-s" with pytest should suspend/resume fixture capturing.""" p1 = pytester.makepyfile(