Commit f0576dc
committed
Support PEP420 (implicit namespace packages) as
Previously, when running `--pyargs pkg`, if you didn't have `pkg/__init__.py`,
pytest would fail with `ERROR: module or package not found: pkg (missing __init__.py?)`.
Now it's discovering the package and tests inside it correctly.
If used in conjunction with `consider_namespace_packages` in config, test
modules get correct `__package__` and `__name__` attributes as well.
Fixes: #478
Other relevant issues:
- #2371
- #10569
In addition, remove `"namespace"` origin handling -- this value isn't used since python 3.8.
See:
- python/cpython#5481
- https://docs.python.org/3/library/importlib.html#importlib.machinery.ModuleSpec.submodule_search_locations--pyargs target.1 parent cfbe319 commit f0576dc
File tree
4 files changed
+19
-4
lines changed- changelog
- src/_pytest
- testing
4 files changed
+19
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| 137 | + | |
137 | 138 | | |
138 | 139 | | |
139 | 140 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
991 | 991 | | |
992 | 992 | | |
993 | 993 | | |
994 | | - | |
| 994 | + | |
| 995 | + | |
995 | 996 | | |
996 | | - | |
997 | | - | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
998 | 1005 | | |
| 1006 | + | |
999 | 1007 | | |
1000 | 1008 | | |
1001 | 1009 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
| 172 | + | |
| 173 | + | |
173 | 174 | | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
174 | 179 | | |
175 | 180 | | |
176 | 181 | | |
| |||
0 commit comments