pytest-dev / pytest-dev/pytest

Deprecate collecting 'test*.txt' files as doctests, replaced by 'test_*.txt'

Open
#5,450 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I've always thought odd that the pattern for collecting doctest files is test*.txt, while for Python files is test_*.py and *_test.py.

How about we deprecate collecting test*.txt files? Sometimes this tries to collect files which are not test files and can be a source of confusion (https://github.com/pytest-dev/pytest/issues/5445 is the most recent example of this but I'm sure there are more). We could emit a warning when we collect such a file and the user did not specify that option explicitly.

After that we should decide to which pattern we should collect by default then:

  1. test_*.txt.
  2. test_*.rst.
  3. Do not collect doctests by default.

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

No files or tests are named; start by tracing pytest's doctest collection behavior and reviewing issue #5445. Decide whether to use test_.txt, test_.rst, or disable default doctest collection, then define the deprecation warning behavior for files collected implicitly versus explicitly.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.