Opened 11 years ago

Closed 11 years ago

Last modified 10 years ago

#6031 closed (fixed)

tests: Don't fail silently if TestCase._pre_setup() raises an exception

Reported by: Thomas Güttler <hv@…> Owned by: nobody
Component: Testing framework Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no



up to now the test runner ends without displaying the results,
if there is an exception in TestCase._pre_setup():

Creating test database...
No fixtures found.
temp /tmp/tmpacM5va
EError: Database test_foo couldn't be flushed. Possible reasons:
      * The database isn't running or isn't configured correctly.
      * At least one of the expected database tables doesn't exist.
      * The SQL was invalid.
    Hint: Look at the output of ' sqlflush'. That's the SQL this command wasn't able to run.
    The full error: current transaction is aborted, commands ignored until end of transaction block

This small patch passes the exception of _pre_setup() to the results of the testcase.

Otherwise it is hard to get the real error. The database error in _pre_setup()
is caused by the first test case. The output, or runnging the output of
' sqlflush' does not help, since the error can be specific to the

Please apply this small patch. All unittests pass after applying it.

Attachments (1)

testcases_exc_in_pre_setup.diff (613 bytes) - added by Thomas Güttler <hv@…> 11 years ago.

Download all attachments as: .zip

Change History (3)

Changed 11 years ago by Thomas Güttler <hv@…>

comment:1 Changed 11 years ago by Russell Keith-Magee

Resolution: fixed
Status: newclosed

(In [7023]) Fixed #6031 -- Added error handling for _pre_test in django.test.TestCase; exceptions during pre-test setup are now reported as test failures, rather than crashing the entire test framework. Thanks, Thomas Guttler <hv@…>.

comment:2 Changed 10 years ago by Thomas Güttler

Cc: hv@… removed
Note: See TracTickets for help on using tickets.
Back to Top