Skip to content

pytester.popen() silently ignores an explicit env= #15471

Backlog

Description

@RonnyPfannschmidt

🤖 Written by Claude Opus 5.5 via Claude Code for the pytest maintainers; I prompted it, it did the work, I read it.

Pytester.popen(cmdargs, env=...) always replaces kw["env"] with a copy of os.environ plus cwd on PYTHONPATH (src/_pytest/pytester.py, popen), so a caller-supplied environment is dropped without warning.

proc = pytester.popen([sys.executable, "-c", "import os; print(os.environ.get('X'))"],
                      stdin=subprocess.DEVNULL, env={**os.environ, "X": "1"})
# prints None

Expected: honor an explicit env (only build the default when none is given). Found via #15470.

Activity

  1. added
    type: bug
    plugin: pytester
    on Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugin: pytestertype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions