Django

Code

Ticket #2490 (closed: fixed)

Opened 2 years ago

Last modified 1 year ago

[patch] make runtests.py error messages more user friendly

Reported by: dev@simon.net.nz Assigned to: adrian
Milestone: Component: Unit test system
Version: SVN Keywords:
Cc: dev@simon.net.nz Triage Stage: Accepted
Has patch: 1 Needs documentation: 1
Needs tests: 0 Patch needs improvement: 1

Description

Patched to check if environ has a DJANGO_SETTINGS_MODULE, when no --settings arg. is present. If no settings module is found, it attempts to load settings.py in the runtests dir. If that doesn't work, then it displays the usage/help and an error message asking for --settings.

I'm aware of ticket:2333 to improve the test framework, but this had me stumped for a while, and might make it easier for others to write/use tests.

Attachments

runtests.diff (0.8 kB) - added by dev@simon.net.nz on 08/05/06 22:37:51.
post_r3661.diff (0.7 kB) - added by dev@simon.net.nz on 08/28/06 03:05:57.
updated patch for post r3661
post_4227.diff (0.7 kB) - added by dev@simon.net.nz on 12/18/06 16:11:33.
update to r4227

Change History

08/05/06 22:37:51 changed by dev@simon.net.nz

  • attachment runtests.diff added.

08/05/06 22:38:07 changed by anonymous

  • summary changed from runtests.py gives a traceback when no settings file is found in the env, or passed as an argument. to [patch] runtests.py gives a traceback when no settings file is found in the env, or passed as an argument..

08/28/06 03:05:57 changed by dev@simon.net.nz

  • attachment post_r3661.diff added.

updated patch for post r3661

12/18/06 16:11:33 changed by dev@simon.net.nz

  • attachment post_4227.diff added.

update to r4227

12/18/06 16:12:53 changed by dev@simon.net.nz

  • summary changed from [patch] runtests.py gives a traceback when no settings file is found in the env, or passed as an argument. to [patch] make runtests.py error messages more user friendly.

02/14/07 11:50:21 changed by Gary Wilson <gary.wilson@gmail.com>

  • needs_better_patch set to 1.
  • stage changed from Unreviewed to Accepted.
  • needs_docs set to 1.

Marking this as accepted since, at the very least, the help text should be printed out.

Also, probably want to use sys.stderr.write() to print the error message instead of the print statement. The error message should mention something about setting DJANGO_SETTINGS_MODULE or using --settings, or at least let the user know that they are seeing the message because DJANGO_SETTINGS_MODULE is not set. Just saying "No settings file found" is not as helpful.

Personally, I don't think we should try to import a settings module in the runtest directory, since this would user code added to the django source tree. Besides, you can use whatever settings you want with the environment variable or the --settings option. If this code is taken out then I would say no documentation is needed, but if it stays then there should be documentation about it.

02/26/07 16:34:56 changed by jacob

  • status changed from new to closed.
  • resolution set to fixed.

(In [4628]) Fixed #2490: Added a polite note to runtests.py about setting DJANGO_SETTINGS_MODULE or --settings.


Add/Change #2490 ([patch] make runtests.py error messages more user friendly)




Change Properties
Action