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

py.test --doctest-modules doesn't skip setup.py #502

Closed
pytestbot opened this Issue Apr 12, 2014 · 9 comments

Comments

Projects
None yet
6 participants
@pytestbot

pytestbot commented Apr 12, 2014

Originally reported by: BitBucket: offbyone, GitHub: offbyone


If I have the following path layout:

/setup.py
/package_name/
/package_name/__init__.py

I expect --doctest-modules not to read in setup.py. I can control it with conftest.py, but that seems a bit iffy. A better way might be to (IF the project is a setuptools package) take advantage of the setuptools project declaration to find the set of modules under test there.

In any case, setup.py should be skipped.


@pytestbot

This comment has been minimized.

pytestbot commented Apr 12, 2014

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


I guess we cannot just skip any basename setup.py because it might be something valid in pkgname/sub/setup.py e.g. But ignoring the toplevel setup.py seems fine, just a question through what means. Hardcoding in pytest source seems not optimal.

@pytestbot

This comment has been minimized.

pytestbot commented Apr 12, 2014

Original comment by BitBucket: offbyone, GitHub: offbyone:


No argument there. There are some useful heuristics that might work, though; you can look for a project root (if so inclined), or maybe take the perspective that any setup.py in the current directory that is not also a package (ie: that doesn't contain init.py) qualifies as a setup.py for the purposes of the plugin.

@pytestbot

This comment has been minimized.

pytestbot commented Nov 26, 2014

Original comment by BitBucket: encukou, GitHub: encukou:


Special-casing the project root isn't a good solution IMO. A project can have sub-packages that are to be installed as separate wheels, but these also need need doctests.

Would it make sense to use wildcard ignores, e.g. **/setup.py ? Or something like --ignore-toplevel=setup.py that checks for nonexistence of a sibling __init__.py?

I suppose I can write a plugin for it, if it's not material for mainline pytest.

@pytestbot

This comment has been minimized.

pytestbot commented Nov 27, 2014

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


UI wise i usually consider it best if things just work without the need to find and set some option. So what about ignoring "setup.py" files from doctests if it contains "distutils" or "setuptools" as a string? Wouldn't this work for almost every case we discussed so far? (It's a heuristic but only applicable to doctests and we can see if anyone complains and if so add an option i guess).

@pytestbot

This comment has been minimized.

pytestbot commented Nov 27, 2014

Original comment by BitBucket: encukou, GitHub: encukou:


Sounds good, combined with the check for top-level module.

@pytestbot

This comment has been minimized.

pytestbot commented Nov 27, 2014

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


PR welcome.

@pytestbot

This comment has been minimized.

pytestbot commented Nov 29, 2014

Original comment by BitBucket: encukou, GitHub: encukou:


OK, it's on my list. (A plugin is the easy part; figuring out pytest's code/tests/docs structure will take some time, as I have other, more pressing, things to do.)

@bilderbuchi

This comment has been minimized.

Contributor

bilderbuchi commented Oct 24, 2017

#2834 has been merged, so this can be closed, right?

@RonnyPfannschmidt

This comment has been minimized.

Member

RonnyPfannschmidt commented Oct 24, 2017

yup, thanks for the note

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment