Opened 3 years ago

Closed 3 years ago

#20198 closed Bug (worksforme)

fixtures.FixtureLoadingTests.test_loaddata_error_message fails on Postgres 9.2

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


Running the 'fixtures' tests against PostgreSQL 9.2.3 fails as follows:

FAIL: test_loaddata_error_message (modeltests.fixtures.tests.FixtureLoadingTests)
Traceback (most recent call last):
  File "/home/clawlor/code/django/tests/modeltests/fixtures/", line 255, in test_loaddata_error_message
    management.call_command('loaddata', 'invalid.json', verbosity=0, commit=False)
AssertionError: "Could not load fixtures.Article\(pk=1\): .*$" does not match "Problem installing fixture '/home/clawlor/code/django/tests/modeltests/fixtures/fixtures/invalid.json': Could not load fixtures.Article(pk=1): null value in column "pub_date" violates not-null constraint
DETAIL:  Failing row contains (1, Breaking news, null).


The failure is due to the newline in the exception message after the word 'constraint'. The test regex expects a match ending with ".*$", which does result in a match against a string containing a newline character that is not at the end of the string.

This test does not fail against PostgreSQL 9.1. The version of psycopg2 used does not matter.

The behavior being tested is clearly not broken, this is a simple matter of updating the test regex. A patch is included which removes the "$" requirement.

Attachments (1)

patch_20198.diff (687 bytes) - added by Chris Lawlor <lawlor.chris@…> 3 years ago.

Download all attachments as: .zip

Change History (3)

Changed 3 years ago by Chris Lawlor <lawlor.chris@…>

comment:1 Changed 3 years ago by Chris Lawlor <lawlor.chris@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 3 years ago by claudep

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

Thanks for the report, but this assertion has been modified in

Note: See TracTickets for help on using tickets.
Back to Top