pytest-dev / pytest-dev/pytest

Forcing `--capture=sys` without passing the CLI flag seems impossible?

Open
#14,444 1 comment 0 reactions 1 assignee View on GitHub

@goodboy is already working on this.

Since Jun 29, 2026.

platform: linux plugin: capture type: question
Dominant language
Python
Stars
14.5k
Forks
3.4k
Avg merge
2d 9h
Merged PRs (30d)
35

Description

  • a detailed description of the bug or problem you are having
    i want to dynamically force capsys in certain specialized cases (specifically using an os.fork()ing process spawning backend in tractor) but haven't been able to figure out a way using what i thought should be the right hook: pytest_load_initial_conftests().

  • output of pip list from the virtual environment you are using
    don't think this is relevant? (but i'll put it if y'all think it's not just noise)

  • pytest and operating system versions

    • pytest 8.3.5 (yeah yeah i know i gotta update 😝)
    • nixos.
  • minimal example if possible

    i have the above hook implemented in a way that detects the passed CLI opts and tries to force it by appending to args here,

https://github.com/goodboy/tractor/pull/447/changes#r3198334549

i then have a dynamic fixture requesting fixture here which tries to do something similar on a per-test declaration basis here,

https://github.com/goodboy/tractor/pull/447/changes#r3198340745

I'm wondering if what i'm doing is expected to work or not?

Ideally we can allow users to run our test suite without having to fail-early-after-pytest invocation when they do not pass pytest --capture=sys, IOW if a certain backend is parametrized into the overall run (specifially in our case with --spawn-backend=main_thread_forkserver) then we want to automatically apply as though pytest --capture=sys --spawn-backend=<backend> as well?

Please lmk what info is necessary to dig into this.
Also obviously yell at me about updating the pytest version (which we're already getting nudged about).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.