Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run pexpect tests on CI by default #12884

Open
The-Compiler opened this issue Oct 13, 2024 · 0 comments
Open

Run pexpect tests on CI by default #12884

The-Compiler opened this issue Oct 13, 2024 · 0 comments
Labels
type: selftests a problem in the tests of pytest

Comments

@The-Compiler
Copy link
Member

  • pytester tests that require pexpect are silently skipped if pexpect is unavailable:

pexpect = importorskip("pexpect", "3.0")

  • We default to not installing pexpect even on CI, only having it as an optional dependency with a -pexpect factor:

pytest/tox.ini

Line 79 in f373974

pexpect: pexpect>=4.8.0

  • The only CI environment where we include that is a Python 3.8 one:

- name: "ubuntu-py38"
python: "3.8"
os: ubuntu-latest
tox_env: "py38-lsof-numpy-pexpect"
use_coverage: true

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

def spawn(self, cmd: str, expect_timeout: float = 10.0) -> pexpect.spawn:
"""Run a command using pexpect.
The pexpect child is returned.
"""
pexpect = importorskip("pexpect", "3.0")
if hasattr(sys, "pypy_version_info") and "64" in platform.machine():
skip("pypy-64 bit not supported")
if not hasattr(pexpect, "spawn"):
skip("pexpect.spawn not available")
logfile = self.path.joinpath("spawn.out").open("wb")
child = pexpect.spawn(cmd, logfile=logfile, timeout=expect_timeout)
self._request.addfinalizer(logfile.close)
return child

I think we should either:

  • Figure out if we can change Pytester in a backwards-compatible way to use the cross-platform PopenSpawn instead. Pexpect claims:

PopenSpawn is not a direct replacement for spawn. Many programs only offer interactive behaviour if they detect that they are running in a terminal. When run by PopenSpawn, 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).
@The-Compiler The-Compiler added the type: selftests a problem in the tests of pytest label Oct 13, 2024
The-Compiler added a commit to The-Compiler/pytest that referenced this issue Oct 13, 2024
Python 3.13 makes pdb break on the breakpoint() call,
rather than on the next line:
https://docs.python.org/3/whatsnew/3.13.html#pdb

Also runs the pdb tests on Python 3.13 in CI.
See pytest-dev#12884 for a more proper solution for that.

Fixes pytest-dev#12497
The-Compiler added a commit to The-Compiler/pytest that referenced this issue Oct 13, 2024
Python 3.13 makes pdb break on the breakpoint() call,
rather than on the next line:
https://docs.python.org/3/whatsnew/3.13.html#pdb

Also runs the pdb tests on Python 3.13 in CI.
See pytest-dev#12884 for a more proper solution for that.

Fixes pytest-dev#12497
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: selftests a problem in the tests of pytest
Projects
None yet
Development

No branches or pull requests

2 participants
@The-Compiler and others