Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#30403 closed Bug (invalid)

Test namespace packages discover fails to load module.

Reported by: Jonny Fuller Owned by: nobody
Component: Testing framework Version: 2.2
Severity: Normal Keywords: namespace packages
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Jonny Fuller)

Hello friends. Test discovery with namespaced packages fails when selecting a subpackage because of the way unittest discover evaluates paths. A reproducible example repository and full documentation can be found here. However, if you test the entire namespace, or a specific test module, everything works.

I'm not sure what the solution is, but it may have something to do with how the test runner calls discover.

<EDIT> I tried the same situation with just the normal Python unittest module discovery and it still occurs. Looks like this may be a Python problem and not a Django problem.

Change History (4)

comment:1 by Jonny Fuller, 5 years ago

Description: modified (diff)

comment:2 by Mariusz Felisiak, 5 years ago

Resolution: invalid
Status: newclosed
Summary: Test namespace packages discover fails to load moduleTest namespace packages discover fails to load module.

Thanks for the report, however it is not an issue in Django. IMO namespace/__init__.py is missing. touch namespace/__init__.py fixed all issues for me.

in reply to:  2 comment:3 by Jonny Fuller, 5 years ago

Replying to felixxm:

Thanks for the report, however it is not an issue in Django. IMO namespace/__init__.py is missing. touch namespace/__init__.py fixed all issues for me.

Hi felixxm. Namespace packages are not supposed to have an init. Anyway, this is a Python bug not a Django bug so I reported it https://bugs.python.org/issue36723 but I don't see any movement on it.

comment:4 by Roger Gammans, 5 years ago

Adding a \_\_init\_\_.py prevents distrubition from outside the current directory contribuitng to the namepscae packages; so would in my case break my application. ( But this I'l follwo this up on the cpython bug )

Note: See TracTickets for help on using tickets.
Back to Top