Opened 18 years ago
Closed 18 years ago
#2490 closed enhancement (fixed)
[patch] make runtests.py error messages more user friendly
Reported by: | 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)
Change History (7)
by , 18 years ago
Attachment: | runtests.diff added |
---|
comment:1 by , 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 , 18 years ago
Attachment: | post_r3661.diff added |
---|
comment:2 by , 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 , 18 years ago
Needs documentation: | set |
---|---|
Patch needs improvement: | set |
Triage Stage: | Unreviewed → Accepted |
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 , 18 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
updated patch for post r3661