Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#16645 closed Bug (fixed)

OldFormForXTests.test_image_field fails under Oracle

Reported by: Aymeric Augustin Owned by: nobody
Component: Forms Version: 1.3
Severity: Release blocker Keywords: oracle
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Attachments (1)

16645.patch (1.4 KB) - added by Aymeric Augustin 8 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 8 years ago by Aymeric Augustin

Triage Stage: UnreviewedAccepted

comment:2 Changed 8 years ago by Aymeric Augustin

Keywords: oracle added

comment:3 Changed 8 years ago by Aymeric Augustin

I can't reproduce this under Oracle 10. The CI server is running Oracle 11, it may explain the difference.

comment:4 Changed 8 years ago by Aymeric Augustin

The problem is in modeltests/model_forms/, in a test for ImageField, at line 1320:

        self.assertEqual(, None)

In the same file, there's an equivalent test for FileField, at line 1192 — but it's written slightly differently:

        self.assertEqual(, '')

I suggest to make the test for ImageField similar to the test for FileField. See attached patch.

With this patch, the tests still pass under SQLite, MySQL, PostgreSQL and Oracle 10. I don't have access to Oracle 11, but it's very likely that the change will fix the failing test; the CI will tell us.

Changed 8 years ago by Aymeric Augustin

Attachment: 16645.patch added

comment:5 Changed 8 years ago by Aymeric Augustin

Also, this patch enforces a best practice, namely not using null=True on text-based fields.

comment:6 Changed 8 years ago by Aymeric Augustin

IRC discussion about this patch:

2011-08-28 15:36:35 <cramm> about the test failure with Oracle 11 related to a nullable filefield
2011-08-28 15:37:18 <cramm> I've been reviewing it. I don't feel comfortable with adapting the tests to workaround that
2011-08-28 15:38:37 <cramm> I know there is some recommendation in the charfield docs discouraging using null=True, but we have a handful of models containing FileField's and ImageField's with null=True in out tests, and they work correctly
2011-08-28 15:39:57 <cramm> ... and a bunch of models with other CharField-derived fields also with null=True. In some tests we even test for ORM behavior when confronted with the null=Tree
2011-08-28 15:40:42 <mYk> cramm: the problem here is that we test that an ImageField with no value has its name set to ''
2011-08-28 15:40:47 <cramm> So, I'd prefer to see first why things don't fail in Oracle 10g and fail in 11g
2011-08-28 15:41:03 <mYk> but since the field is nullable the result should be None
2011-08-28 15:41:47 <mYk> the docs don't say exactly how <file>.name is supposed to behave, but basically, it's the string stored in the db
2011-08-28 15:42:46 <mYk> in short, I agree that I didn't nail the root cause, and the expected behavior of <file>.name is underdefined
2011-08-28 15:43:09 <cramm> I gree with the latter :)
Last edited 8 years ago by Ramiro Morales (previous) (diff)

comment:7 Changed 8 years ago by Ian Kelly

I am able to reproduce the failure using Oracle 10g. This kind of thing has come up before in the tests. The usual fix is to predicate the expected output on the "interprets_empty_strings_as_nulls" feature.

comment:8 Changed 8 years ago by Ian Kelly

Resolution: fixed
Status: newclosed

In [16919]:

Fixed #16645: fixed a broken test to work in Oracle.

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