-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Parent module '' not loaded - relative import in PEP 420 namespace package #1927
Labels
plugin: doctests
related to the doctests builtin plugin
type: enhancement
new feature or API change, should be merged into features branch
Comments
jaraco
added a commit
to pmxbot/pmxbot.rss
that referenced
this issue
Sep 10, 2016
Pytest is currently unaware of pep404 I can't search for it on mobile |
I just made https://github.com/Mortal/doctestmod to work around this problem. |
Thanks @Mortal, that can be used as basis for a solution in pytest! |
nicoddemus
added
plugin: doctests
related to the doctests builtin plugin
type: enhancement
new feature or API change, should be merged into features branch
labels
Sep 29, 2017
the message has changed but still errors:
|
ttung
pushed a commit
to ttung/napari
that referenced
this issue
Jan 27, 2020
I considered making all the tests namespace packages, but it turns out pytest [chokes](pytest-dev/pytest#3396) [on](pytest-dev/pytest#1927) [namespace packages](pytest-dev/pytest#478). So this is the best solution for now. Test plan: made a distribution (python setup.py sdist) then installed it in a separate virtualenv. then ran tests (`pytest --pyargs napari`).
ttung
pushed a commit
to ttung/napari
that referenced
this issue
Jan 27, 2020
I considered making all the tests namespace packages, but it turns out pytest [chokes](pytest-dev/pytest#3396) [on](pytest-dev/pytest#1927) [namespace packages](pytest-dev/pytest#478). So this is the best solution for now. Test plan: made a distribution (python setup.py sdist) then installed it in a separate virtualenv. then ran tests (`pytest --pyargs napari`). Fixes napari#875
8 tasks
ttung
pushed a commit
to ttung/napari
that referenced
this issue
Jan 27, 2020
I considered making all the tests namespace packages, but it turns out pytest [chokes](pytest-dev/pytest#3396) [on](pytest-dev/pytest#1927) [namespace packages](pytest-dev/pytest#478). So this is the best solution for now. Test plan: made a distribution (python setup.py sdist) then installed it in a separate virtualenv. then ran tests (`pytest --pyargs napari`). Fixes napari#875
ttung
pushed a commit
to ttung/napari
that referenced
this issue
Jan 28, 2020
I considered making all the tests namespace packages, but it turns out pytest [chokes](pytest-dev/pytest#3396) [on](pytest-dev/pytest#1927) [namespace packages](pytest-dev/pytest#478). So this is the best solution for now. Test plan: made a distribution (python setup.py sdist) then installed it in a separate virtualenv. then ran tests (`pytest --pyargs napari`). Fixes napari#875
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: enhancement
new feature or API change, should be merged into features branch
When pytest is collecting packages for the purpose of doctesting modules, it can encounter an error when that module performs a relative import in a PEP-420 namespace package. Consider this trivially simple example:
The namespace package is
pkg
and because it has no__init__.py
and because both.
and../dir2
are on sys.path, the two modulespkg.mod1
andpkg.mod2
share the namespace. As you can see, when imported naturally, the relative import works just fine. When imported for the purpose of discovering doctests, the namespace loader is not used, so__package__
isn't defined, and relative imports won't work.That's as much as I understand right now, so I'm just registering this issue to capture my findings.
The text was updated successfully, but these errors were encountered: