pytest-dev / pytest-dev/pytest

pytest_load_initial_conftests not called for conftest plugins (arg manipulation)

Open
#5,024 15 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: bug
Dominant language
Python
Stars
14.5k
Forks
3.4k
Avg merge
2d 9h
Merged PRs (30d)
35

Description

Hi! I'm trying to find a way to use doctests, but not for Windows. It seems that there's a way to do this at: https://docs.pytest.org/en/latest/example/simple.html#dynamically-adding-command-line-options

I tried the following minimal example but it did not work:

import platform

def pytest_load_initial_conftests(args):
    if platform.system() != 'Windows':
        args[:] = args + ['--doctest-modules']

Is there something I'm missing here?

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.

Research direction

Start with the documentation example for dynamically adding command-line options and trace how pytest_load_initial_conftests is discovered for conftest plugins. Reproduce the minimal example on a non-Windows system, then inspect the relevant hook-loading behavior. Done means the hook can add --doctest-modules as shown, with coverage for the reported case.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.