#26570: Test runner imports module package with Python 3.5+
-----------------------------------+--------------------
     Reporter:  bronger            |      Owner:  nobody
         Type:  Bug                |     Status:  new
    Component:  Testing framework  |    Version:  1.9
     Severity:  Normal             |   Keywords:
 Triage Stage:  Unreviewed         |  Has patch:  0
Easy pickings:  0                  |      UI/UX:  0
-----------------------------------+--------------------
 Since Python 3.5, unittest's runner searches for tests also in all
 `__init__.py` modules.  The release notes say:

     Found packages are now checked for load_tests regardless of
     whether their path matches pattern, because it is impossible for
     a package name to match the default pattern.

 If you organise your models in a package rather than a single `models.py`
 (the `__init__.py` file contains commands like `from submodule import *`
 to collect all model classes in the package), this leads to an error in a
 bogus test saying that the app is not ready yet.  This happens because the
 model classes are executed, and this occurs too early (it should not occur
 at all).

 A workaround is to say

 {{{
 manage.py test myapp/tests
 }}}

 instead of

 {{{
 manage.py test myapp
 }}}

 if your tests live in `tests/` and only there.

--
Ticket URL: <https://code.djangoproject.com/ticket/26570>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.c0768a86824466edddf0bc1bbec0efa8%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to