Opened 12 years ago

Closed 12 years ago

#20198 closed Bug (worksforme)

fixtures.FixtureLoadingTests.test_loaddata_error_message fails on Postgres 9.2

Reported by: Chris Lawlor Owned by: nobody
Component: Testing framework Version: dev
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

Description

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/tests.py", 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@…> 12 years ago.

Download all attachments as: .zip

Change History (3)

by Chris Lawlor <lawlor.chris@…>, 12 years ago

Attachment: patch_20198.diff added

comment:1 by Chris Lawlor <lawlor.chris@…>, 12 years ago

comment:2 by Claude Paroz, 12 years ago

Resolution: worksforme
Status: newclosed

Thanks for the report, but this assertion has been modified in https://github.com/django/django/commit/c9166733#L253

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