Re: [Django] #11593: Incomplete support for app-level testing

17 views
Skip to first unread message

Django

unread,
Dec 12, 2018, 10:03:24 AM12/12/18
to django-...@googlegroups.com
#11593: Incomplete support for app-level testing
-------------------------------------+-------------------------------------
Reporter: Masklinn | Owner: Raphael
| Kimmig
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Raphael Kimmig):

* 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.

Django

unread,
Dec 18, 2018, 2:29:31 AM12/18/18
to django-...@googlegroups.com
#11593: Incomplete support for app-level testing
-------------------------------------+-------------------------------------
Reporter: Masklinn | Owner: Raphael
| Kimmig
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Dec 18, 2018, 2:29:59 AM12/18/18
to django-...@googlegroups.com
#11593: Incomplete support for app-level testing
-------------------------------------+-------------------------------------
Reporter: Masklinn | Owner: Raphael
| Kimmig
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Raphael Kimmig):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/11593#comment:11>

Django

unread,
Dec 18, 2018, 9:40:04 AM12/18/18
to django-...@googlegroups.com
#11593: Incomplete support for app-level testing
-------------------------------------+-------------------------------------
Reporter: Masklinn | Owner: Raphael
| Kimmig
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Dec 18, 2018, 11:06:49 AM12/18/18
to django-...@googlegroups.com
#11593: Incomplete support for app-level testing
-------------------------------------+-------------------------------------
Reporter: Masklinn | Owner: Raphael
| Kimmig
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Dec 18, 2018, 1:50:39 PM12/18/18
to django-...@googlegroups.com
#11593: Incomplete support for app-level testing
-------------------------------------+-------------------------------------
Reporter: Masklinn | Owner: Raphael
| Kimmig
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Dec 18, 2018, 1:56:51 PM12/18/18
to django-...@googlegroups.com
#11593: Incomplete support for app-level testing
-----------------------------------+------------------------------------
Reporter: Masklinn | Owner: (none)
Type: New feature | Status: new

Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by egmanoj):

* owner: Raphael Kimmig => (none)
* status: assigned => new


--
Ticket URL: <https://code.djangoproject.com/ticket/11593#comment:15>

Django

unread,
Dec 18, 2018, 1:57:40 PM12/18/18
to django-...@googlegroups.com
#11593: Incomplete support for app-level testing
-----------------------------------+------------------------------------
Reporter: Masklinn | Owner: (none)
Type: New feature | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------

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>

Django

unread,
Dec 20, 2018, 9:02:21 PM12/20/18
to django-...@googlegroups.com
#11593: Incomplete support for app-level testing
-------------------------------------+-------------------------------------
Reporter: Masklinn | Owner: Raphael
| Kimmig
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* cc: egmanoj@… (removed)


--
Ticket URL: <https://code.djangoproject.com/ticket/11593#comment:15>

Django

unread,
Feb 15, 2019, 6:11:24 AM2/15/19
to django-...@googlegroups.com
#11593: Incomplete support for app-level testing
-------------------------------------+-------------------------------------
Reporter: Masklinn | Owner: Raphael
| Kimmig
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* 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>

Django

unread,
Mar 25, 2024, 7:55:16 AMMar 25
to django-...@googlegroups.com
#11593: Incomplete support for app-level testing
-----------------------------------+------------------------------------
Reporter: Masklinn | Owner: (none)
Type: New feature | Status: new
Component: Testing framework | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by Mariusz Felisiak):

* owner: Raphael Kimmig => (none)
* status: assigned => new

--
Ticket URL: <https://code.djangoproject.com/ticket/11593#comment:17>

Django

unread,
Mar 26, 2024, 3:22:38 AMMar 26
to django-...@googlegroups.com
#11593: Incomplete support for app-level testing
-------------------------------------+-------------------------------------
Reporter: Masklinn | Owner: Raphael
| Kimmig
Type: New feature | Status: assigned
Component: Testing framework | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Raphael Kimmig):

* owner: (none) => Raphael Kimmig
* status: new => assigned

Comment:

I forgot about this completely. I'll just fix up the branch and add in the
feedback.
--
Ticket URL: <https://code.djangoproject.com/ticket/11593#comment:18>

Django

unread,
Mar 26, 2024, 3:34:09 AMMar 26
to django-...@googlegroups.com
#11593: Incomplete support for app-level testing
-------------------------------------+-------------------------------------
Reporter: Masklinn | Owner: Raphael
| Kimmig
Type: New feature | Status: assigned
Component: Testing framework | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Mariusz Felisiak):

Replying to [comment:18 Raphael Kimmig]:
> I forgot about this completely. I'll just fix up the branch and add in
the feedback.

Great, thanks!
--
Ticket URL: <https://code.djangoproject.com/ticket/11593#comment:19>

Django

unread,
Mar 26, 2024, 4:28:24 AMMar 26
to django-...@googlegroups.com
#11593: Incomplete support for app-level testing
-------------------------------------+-------------------------------------
Reporter: Masklinn | Owner: Raphael
| Kimmig
Type: New feature | Status: assigned
Component: Testing framework | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Raphael Kimmig):

I wasn't able to change the target branch on the old PR to main, so here
is a new one incorporating feedback from the old PR

https://github.com/django/django/pull/18018
--
Ticket URL: <https://code.djangoproject.com/ticket/11593#comment:20>
Reply all
Reply to author
Forward
0 new messages