Django

Code

Ticket #6031 (closed: fixed)

Opened 1 year ago

Last modified 3 months ago

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

Reported by: Thomas Güttler <hv@tbz-pariv.de> Assigned to: nobody
Milestone: Component: Testing framework
Version: SVN Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

Hi,

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

Creating test database...
[cut]
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 'django-admin.py 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 'django-admin.py sqlflush' does not help, since the error can be specific to the testdatabase.

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

Attachments

testcases_exc_in_pre_setup.diff (0.6 kB) - added by Thomas Güttler <hv@tbz-pariv.de> on 11/26/07 04:37:50.

Change History

11/26/07 04:37:50 changed by Thomas Güttler <hv@tbz-pariv.de>

  • attachment testcases_exc_in_pre_setup.diff added.

01/18/08 07:37:40 changed by russellm

  • status changed from new to closed.
  • resolution set to fixed.

(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@tbz-pariv.de>.

09/04/08 09:58:07 changed by guettli

  • cc deleted.
  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

Add/Change #6031 (tests: Don't fail silently if TestCase._pre_setup() raises an exception)




Change Properties
Action