Opened 18 years ago

Closed 18 years ago

#2490 closed enhancement (fixed)

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

Reported by: dev@… Owned by: Adrian Holovaty
Component: Testing framework Version: dev
Severity: minor Keywords:
Cc: dev@… Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

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 (3)

runtests.diff (778 bytes ) - added by dev@… 18 years ago.
post_r3661.diff (729 bytes ) - added by dev@… 18 years ago.
updated patch for post r3661
post_4227.diff (721 bytes ) - added by dev@… 18 years ago.
update to r4227

Download all attachments as: .zip

Change History (7)

by dev@…, 18 years ago

Attachment: runtests.diff added

comment:1 by anonymous, 18 years ago

Summary: runtests.py gives a traceback when no settings file is found in the env, or passed as an argument.[patch] runtests.py gives a traceback when no settings file is found in the env, or passed as an argument.

by dev@…, 18 years ago

Attachment: post_r3661.diff added

updated patch for post r3661

by dev@…, 18 years ago

Attachment: post_4227.diff added

update to r4227

comment:2 by dev@…, 18 years ago

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

comment:3 by Gary Wilson <gary.wilson@…>, 18 years ago

Needs documentation: set
Patch needs improvement: set
Triage Stage: UnreviewedAccepted

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.

comment:4 by Jacob, 18 years ago

Resolution: fixed
Status: newclosed

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

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