* owner: nobody => Raphael Kimmig
* status: new => assigned
Comment:
This ticket is really old, but I'd still love to see some progress here.
I've been thinking about this a bit lately and below are my thoughts so
far.
We probably don't need to write a lot of code here, but rather add some
documentation to the advanced tutorial as well as the advanced testing
documentation.
From what I can see there are a few common things that should be
documented.
1. How to run tests in a stand alone application (this requires settings).
2. How to manage settings for running tests in a stand alone application.
3. How to set up views/urls/middleware ... for tests.
4. How to add models specifically for tests inside applications.
For 1, 2 and 3. there are several solutions, to get started I'd probably
describe
how to use `django-admin test` to run the tests with a custom
`test_settings.py`
file.
For 4. there is a simple solution if the app doesn't provide any models
itself.
In that case one can simply disable migrations for the app in the test
settings.
Ideally I'd like to try implementing a `@test_model` decorator as
suggested in
https://code.djangoproject.com/ticket/7835 which would also solve the
general
case.
I'd love to have the documentation for reusable apps contain (directly, or
via links
to the testing docs) all the information required to not only create an
app, but also
make sure it has working tests.
I'll try to expand the relevant docs over the next few days. If anyone has
some
input on the matter I'd be glad to hear it.
Did I miss any obvious work in that area? Maybe even somewhere in the
documentation?
Do you have any suggestions on how specific aspects should be solved?
--
Ticket URL: <https://code.djangoproject.com/ticket/11593#comment:9>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by Raphael Kimmig):
I've added documentation to the resuable apps intro.
[https://github.com/django/django/pull10765 PR]
One possible way to improve this would be to add a `--reusable` flag to
the `test` management command so that one could run the tests with
`django-admin test --reusable` or something along those lines instead of
copy & pasting a `runtests.py` file. Any thoughts?
--
Ticket URL: <https://code.djangoproject.com/ticket/11593#comment:10>
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/11593#comment:11>
Comment (by Simon Charette):
Is there a reason why `python -m django test --settings=tests.settings
tests` (given `tests.test_settings` is renamed to `settings`) wouldn't
work?
That's the pattern I use for all the third party apps I maintain and it
seems to be working just fine.
e.g.
- https://github.com/charettes/django-
seal/blob/36dde326783d51d1f45348fcb18cfd1418e93881/tox.ini#L20
- https://github.com/charettes/django-
seal/tree/36dde326783d51d1f45348fcb18cfd1418e93881/tests
I'm not sure I'm following why a `--reusable` flag is required.
--
Ticket URL: <https://code.djangoproject.com/ticket/11593#comment:12>
Comment (by Raphael Kimmig):
No good reason at all, that looks much nicer actually :-)
I'll update the PR and I'll change the advanced testing part about
reusable applications as well,
unless you see a good reason to suggest using a runtests.py file there.
--
Ticket URL: <https://code.djangoproject.com/ticket/11593#comment:13>
Comment (by Simon Charette):
I don't see a reason for shipping a `runtests.py` file with minimal
configuration. The one we use for Django's testsuite happens to exist
because we need to perform quite a lot of tweaks before running the tests
which isn't the case for most Django third party apps.
--
Ticket URL: <https://code.djangoproject.com/ticket/11593#comment:14>
* owner: Raphael Kimmig => (none)
* status: assigned => new
--
Ticket URL: <https://code.djangoproject.com/ticket/11593#comment:15>
Comment (by egmanoj):
Terribly sorry for de-assigning. Was trying to remove myself from the `cc`
list.
--
Ticket URL: <https://code.djangoproject.com/ticket/11593#comment:16>
* cc: egmanoj@… (removed)
--
Ticket URL: <https://code.djangoproject.com/ticket/11593#comment:15>
* needs_better_patch: 0 => 1
Comment:
Patch looks good. Comments on PR (Summary: Just some rewording to the
"Advanced testing topics" section linked from the new examples needed.)
--
Ticket URL: <https://code.djangoproject.com/ticket/11593#comment:16>