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.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/26570#comment:1>
Comment (by claudep):
#26576 was a duplicate with some other symptoms described.
--
Ticket URL: <https://code.djangoproject.com/ticket/26570#comment:2>
Comment (by timgraham):
I can't reproduce with the tutorial and a models structure that looks like
this:
{{{
polls/models
__init__.py: from .models import *
models.py (copied from `polls/models.py`)
}}}
Did I do something incorrectly or am I missing some detail to reproduce
this?
--
Ticket URL: <https://code.djangoproject.com/ticket/26570#comment:3>
Comment (by bronger):
Isn't `__init__.py` loaded at all, or does it simply not throw an
exception?
--
Ticket URL: <https://code.djangoproject.com/ticket/26570#comment:4>
Comment (by timgraham):
I'm not sure what you're asking.
--
Ticket URL: <https://code.djangoproject.com/ticket/26570#comment:5>
* status: new => closed
* resolution: => needsinfo
--
Ticket URL: <https://code.djangoproject.com/ticket/26570#comment:6>
* status: closed => new
* resolution: needsinfo =>
Comment:
http://stackoverflow.com/a/37098808/188108 is due to the same problem. I
had an `__init__.py` in the project's root directory when I ran my tests.
So maybe this is the reason why Tim could not reproduce it.
I need this `__init__.py` because the project is mounted in sub-
directories of other projects. However, I admit that it may be an exotic
use case.
--
Ticket URL: <https://code.djangoproject.com/ticket/26570#comment:7>
Comment (by Tim Graham):
Are you able to suggest a solution or propose a patch?
--
Ticket URL: <https://code.djangoproject.com/ticket/26570#comment:8>
* status: new => closed
* resolution: => needsinfo
Comment:
I don't know enough to determine if this is something we should/can fix in
Django. I think someone with the use case will have to provide a patch.
--
Ticket URL: <https://code.djangoproject.com/ticket/26570#comment:9>