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

Configuring pytest to pick up "*.py" accidentally pulls in setup.py #88

Open
ferdnyc opened this issue Jun 12, 2024 · 2 comments
Open

Comments

@ferdnyc
Copy link

ferdnyc commented Jun 12, 2024

As noted in aboutcode-org/saneyaml#15, the pytest configuration in pyproject.toml currently configures it to pick up *.py:

https://github.com/nexB/skeleton/blob/acf94b360d675087195b7f216f4bee4401609729/pyproject.toml#L10
https://github.com/nexB/skeleton/blob/acf94b360d675087195b7f216f4bee4401609729/pyproject.toml#L43

This causes it to pick up the setup.py file as a potential test file, and even though it will contain no tests, importing setup.py during testing can have unwanted side effects. (For one, it makes setuptools a dependency of the test environment, where it would otherwise normally not be.)

Unfortunately, reading through the pytest documentation, it doesn't seem as though there's an easy way to exclude specific files once they've been caught up in an inclusion glob.

@ferdnyc
Copy link
Author

ferdnyc commented Jun 12, 2024

The default python_files globs are test_*.py and *_test.py, so unless there's some reason it isn't feasible to name all test files using one of those two patterns, it might be best to just remove the python_files = "*.py" line and use the default value.

@ferdnyc
Copy link
Author

ferdnyc commented Jun 12, 2024

CC: @pombredanne

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant