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

No __init__.py in tests #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

flying-sheep
Copy link

The tests directory isn't a Python package and shouldn't be imported. Don't have any __init__.py files there.

@jerry-git
Copy link
Collaborator

Not sure about this one 🤔 This is from the pytest docs:
Screenshot 2022-08-12 at 10 20 08

So, I think it should be fine as we are using the src layout 🙂

@flying-sheep
Copy link
Author

flying-sheep commented Aug 12, 2022

we are using the src layout

that means you’re using a src directory wherein your package resides, it has nothing to do with the __init__.py.

To learn about that, plase read these excerpts from the document I linked:

If you need to have test modules with the same name, you might add __init__.py files to your test folder and subfolders, changing them to packages:

Note the If above, and the Note below:

The --import-mode=importlib option (see Import modes) does not have any of the drawbacks above because sys.path is not changed when importing test modules, so users that run into this issue are strongly encouraged to try it.

Regarding the pytest docs, I’ll try to make that more accessible: pytest-dev/pytest#10206

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

Successfully merging this pull request may close these issues.

None yet

2 participants