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

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

Open
nicoddemus opened this issue Jun 15, 2019 · 4 comments
Labels
plugin: doctests related to the doctests builtin plugin type: deprecation feature that will be removed in the future type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature

Comments

@nicoddemus
Copy link
Member

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 (#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.
@nicoddemus nicoddemus added type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature plugin: doctests related to the doctests builtin plugin type: deprecation feature that will be removed in the future labels Jun 15, 2019
@RonnyPfannschmidt
Copy link
Member

the intent here is simple, doctests in documentation have no test prefix

we should reqire however to tell pytest the documentation folders/files more explicit (aka doctest_collectroot as a ini option)

@nicoddemus
Copy link
Member Author

the intent here is simple, doctests in documentation have no test prefix

Not sure what you mean, as only test*.txt files are collected as tests?

@RonnyPfannschmidt
Copy link
Member

indeed, i missremembered,

def _is_doctest(config, path, parent):
if path.ext in (".txt", ".rst") and parent.session.isinitpath(path):
return True
globs = config.getoption("doctestglob") or ["test*.txt"]
for glob in globs:
if path.check(fnmatch=glob):
return True
return False
is scarry

@nicoddemus
Copy link
Member Author

I'm leaning towards that 3) might be the best option:

  • Doctests are not widely used, so makes sense to make them opt-in.
  • Principle of least surprise: it is kind of surprising that test*.txt are collected as test files. While it might be innocuous (nothing happens if there are no doctests inside the files), it might be lead to confusing errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: doctests related to the doctests builtin plugin type: deprecation feature that will be removed in the future type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature
Projects
None yet
Development

No branches or pull requests

2 participants