Code

Opened 8 years ago

Closed 8 years ago

#2669 closed defect (fixed)

Test system cannot differentiate between missing tests.py and import error in tests.py

Reported by: russellm Owned by: russellm
Component: Testing framework Version: master
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Ned Batchelder reports that because the test runner uses speculative imports to find tests that may or may not exist, ImportErrors in the tests themselves are usually cloaked, and are hard to debug.

One suggested fix is to modify django/test/simple.py, line 41, to this:

   except ImportError, exc:
       # No tests.py file for application, or some other import error.
       if str(exc) != 'No module named %s' % TEST_MODULE:
           # It's something other than a missing tests module, probably
a real
           # error, so show the user.
           import traceback
           traceback.print_exc()

This is less than ideal; testing error strings is fragile and prone to locale problems. Testing for the existence of tests.py is also unreliable; tests may be a directory module.

Attachments (0)

Change History (2)

comment:1 Changed 8 years ago by russellm

  • Status changed from new to assigned

comment:2 Changed 8 years ago by russellm

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

(In [3740]) Fixes #2669 -- Added check on import of tests.py to differentiate between an absent tests.py, and an existent tests.py with an import error in it.

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.