Description
pytester
tests that requirepexpect
are silently skipped ifpexpect
is unavailable:
pytest/src/_pytest/pytester.py
Line 1513 in f373974
- We default to not installing
pexpect
even on CI, only having it as an optional dependency with a-pexpect
factor:
Line 79 in f373974
- The only CI environment where we include that is a Python 3.8 one:
pytest/.github/workflows/test.yml
Lines 116 to 120 in f373974
-
Yet, we have 40 (!) selftests that use
pexpect
- most notably, most of test_debugging.py (38 of 59 skipped) -
And that caused us to miss [Python 3.13.0b2]
test_pdb_used_outside_test
andtest_pdb_used_in_generate_tests
are failing with Python 3.13 #12497 on our own CI
Why is pexpect an optional factor at all? From what I can gather, that was introduced in bd8a2cc because "it doesn't install on Windows anymore" back in 2013.
Nowadays, it seems to be partially available for Windows, though not pexpect.spawn
which we use for Pytester.spawn()
:
pytest/src/_pytest/pytester.py
Lines 1508 to 1522 in f373974
I think we should either:
- Figure out if we can change
Pytester
in a backwards-compatible way to use the cross-platformPopenSpawn
instead. Pexpect claims:
PopenSpawn
is not a direct replacement forspawn
. Many programs only offer interactive behaviour if they detect that they are running in a terminal. When run byPopenSpawn
, they may behave differently.
- Or if not, at least install
pexpect
unconditionally on Linux (and perhaps macOS) as part of our dev dependencies, using a environment marker (added in pip 6.0 in 2014, so that wasn't an option back when the tox factor was introduced).