Opened 3 years ago

Closed 3 years ago

Last modified 2 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 Changed 3 years ago by Jonny Fuller

Description: modified (diff)

comment:2 Changed 3 years ago by Mariusz Felisiak

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.

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

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 Changed 2 years ago by Roger Gammans

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