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

[FeatureRequest] Add --doctest-only to only collect doctests #4726

Open
dhirschfeld opened this issue Feb 5, 2019 · 8 comments
Open

[FeatureRequest] Add --doctest-only to only collect doctests #4726

dhirschfeld opened this issue Feb 5, 2019 · 8 comments
Labels
plugin: doctests related to the doctests builtin plugin topic: collection related to the collection phase type: enhancement new feature or API change, should be merged into features branch

Comments

@dhirschfeld
Copy link

dhirschfeld commented Feb 5, 2019

When using pytest on CI you often want to test doctests / unittests / intergration tests separately. To enable this usecase it would be good to have a --doctest-only flag to enable running only the doctests

@dhirschfeld
Copy link
Author

@RonnyPfannschmidt
Copy link
Member

based on context i am wondering if we should perhaps move towards making doctestplus the default doctest implementation

if memory serves me right, none of the core devs of pytest are deeply involved or happily using doctest

@nicoddemus
Copy link
Member

if we should perhaps move towards making doctestplus the default doctest implementation

You mean integrating it into the core?

@nicoddemus nicoddemus added type: enhancement new feature or API change, should be merged into features branch type: feature-branch new feature or API change, should be merged into features branch labels Feb 6, 2019
@RonnyPfannschmidt
Copy link
Member

@nicoddemus no, taking it out ^^

@dhirschfeld
Copy link
Author

I'm not fussed where it's implemented - I just opened an issue here since pytest already has some doctest functionality and this would be a great enhancement IMHO.

I'd be happy to install doctestplus if they implemented this - it would be it's killer feature for me!

@RonnyPfannschmidt
Copy link
Member

i started a conversation with the relevant maintainers

@Zac-HD Zac-HD added plugin: doctests related to the doctests builtin plugin topic: collection related to the collection phase labels Sep 26, 2020
@bluetech
Copy link
Member

Because doctest is implemented as a logically independent plugin, there are two implementation strategies/perspectives for achieving this:

In doctest plugin

The doctest plugin adds a --doctest-only flag, implements a hook to filter out any non-doctest items.

Advantages:

  • --doctest-only makes it easy to find for people looking to achieve this particular aim (run only doctests)
  • Can be implemented/isolated in the doctest plugin

Disadvantages:

  • Useless work - regular items are collected only to be discarded
  • Solution is very specific to doctests

In python plugin

The python plugin adds a flag to disable its own collection, e.g. --no-python-modules (name modeled after --doctest-modules, but other options can be --no-py-modules, --no-py-collect, ...)

Advantages/Disadvantages: basically the opposite of previous one.


While I think it made perfect sense for pytest-doctestplus to implement the first solution, I think for pytest the second solution is preferable.

@bluetech
Copy link
Member

BTW, reading the pytest-doctestplus code, what they do is ignore all test_*.py files in --doctest-only mode. But test_*.py can also contain doctests, so IMO this is not very good. But currently they have no alternative if they want to avoid collecting the files/importing the modules (rather than collecting + discarding the items).

@bluetech bluetech removed the type: feature-branch new feature or API change, should be merged into features branch label Feb 17, 2024
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 topic: collection related to the collection phase type: enhancement new feature or API change, should be merged into features branch
Projects
None yet
Development

No branches or pull requests

5 participants