Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#22254 closed Cleanup/optimization (fixed)

Testing documentation doesn't make it clear that django.setup() needs to be called with setup_test_environment

Reported by: peter.landry@… Owned by: Tim Graham <timograham@…>
Component: Documentation Version: 1.7-alpha-2
Severity: Normal Keywords: app-loading
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

https://docs.djangoproject.com/en/dev/topics/testing/advanced/#running-tests-outside-the-test-runner

It's not specific to testing, but it seems that we should mention the necessity of calling django.setup() in the directions for running tests outside of manage.py. I've submitted a pull request with a simple documentation change: https://github.com/django/django/pull/2419

This may require some more discussion, though. As mjtamlyn points out, another solution could be to include django.setup() in setup_test_environment(). The call to django.setup() could also be moved into the example for using setup_test_environment() rather than a warning in its own.

Change History (10)

comment:1 Changed 3 years ago by Marc Tamlyn

Triage Stage: UnreviewedAccepted

comment:2 Changed 3 years ago by Aymeric Augustin

Keywords: app-loading added

comment:3 Changed 3 years ago by peter.landry@…

Perhaps it would be better to add instructions or information regarding django.setup() in https://docs.djangoproject.com/en/dev/ref/applications/, then just make a reference in the testing docs to it in a warning about using django outside of manage.py?

comment:4 Changed 3 years ago by Tim Graham

Has patch: set
Patch needs improvement: set
Type: UncategorizedCleanup/optimization

Yes, it seems like we should enhance the documentation of django.setup(). There's some mentions of it in the 1.7 release notes and a couple other places like docs/ref/django-admin.txt and docs/intro/tutorial01.txt.

comment:5 Changed 3 years ago by Aymeric Augustin

Owner: changed from nobody to Aymeric Augustin
Severity: NormalRelease blocker
Status: newassigned

Indeed, django.setup() isn't correctly documented. Sorry about that.

comment:6 Changed 3 years ago by Aymeric Augustin

https://github.com/django/django/pull/2609 documents django.setup(). Can I haz review?

I'm not convinced it's worth duplicating that information wherever setup_test_environment() is useful. If you hit RuntimeError: App registry isn't ready yet. Google will tell you how to fix it in 10 seconds. I'll let someone else deal with that part if you want to.

comment:7 Changed 3 years ago by Tim Graham

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:8 Changed 3 years ago by Aymeric Augustin

Has patch: unset
Owner: Aymeric Augustin deleted
Severity: Release blockerNormal
Status: assignednew
Triage Stage: Ready for checkinUnreviewed

django.setup() is now properly documented, so we can re-evaluate if something needs to be done for setup_test_environment().

comment:9 Changed 3 years ago by Tim Graham <timograham@…>

Owner: set to Tim Graham <timograham@…>
Resolution: fixed
Status: newclosed

In 26b03f25265227498a2559af807918fe2a1d246f:

Fixed #22254 -- Noted the requirement of calling django.setup() when running

Thanks Peter Landry for the report.

comment:10 Changed 3 years ago by Tim Graham <timograham@…>

In 305ab00087a29ff400e815187b5568f84d2d8739:

[1.7.x] Fixed #22254 -- Noted the requirement of calling django.setup() when running

Thanks Peter Landry for the report.

Backport of 26b03f2526 from master

Note: See TracTickets for help on using tickets.
Back to Top