Code

Opened 8 years ago

Closed 7 years ago

#2490 closed enhancement (fixed)

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

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

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@… 8 years ago.
post_r3661.diff (729 bytes) - added by dev@… 8 years ago.
updated patch for post r3661
post_4227.diff (721 bytes) - added by dev@… 7 years ago.
update to r4227

Download all attachments as: .zip

Change History (7)

Changed 8 years ago by dev@…

comment:1 Changed 8 years ago 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.

Changed 8 years ago by dev@…

updated patch for post r3661

Changed 7 years ago by dev@…

update to r4227

comment:2 Changed 7 years ago by dev@…

  • 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

comment:3 Changed 7 years ago by Gary Wilson <gary.wilson@…>

  • Needs documentation set
  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to 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 Changed 7 years ago by jacob

  • Resolution set to fixed
  • Status changed from new to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.