Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#25108 closed Bug (fixed)

Tests fails when using Pillow 2.9.0

Reported by: Yosuke Yasuda Owned by: Yosuke Yasuda
Component: Forms Version: dev
Severity: Normal Keywords: test
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

A test failed in python3.4.3

$ ./runtests.py ./forms_tests
Testing against Django installed in '/Users/yasudayousuke/oss_hack/django_dev/django_parent/django'
Creating test database for alias 'default'...
Creating test database for alias 'other'...
..................................................................................................................F.....................................................................................................................................................................................................................................................................................................................s...........
======================================================================
FAIL: test_imagefield_annotate_with_bitmap_image_after_clean (forms_tests.tests.test_fields.FieldsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/yasudayousuke/oss_hack/django_dev/django_parent/tests/forms_tests/tests/test_fields.py", line 862, in test_imagefield_annotate_with_bitmap_image_after_clean
    self.assertIsNone(uploaded_file.content_type)
AssertionError: 'image/bmp' is not None

Probably the cause is the change of library Pillow added few days ago.
https://github.com/python-pillow/Pillow/commit/fe18b039ca9e11c6deed8f21a9e5eca815badbb7

My Pillow version is 2.9.0, so the content_type is "image/bmp" and is not None.

Attachments (1)

25108.diff (583 bytes ) - added by Yosuke Yasuda 9 years ago.

Download all attachments as: .zip

Change History (9)

by Yosuke Yasuda, 9 years ago

Attachment: 25108.diff added

comment:1 by Yosuke Yasuda, 9 years ago

Owner: changed from nobody to Yosuke Yasuda
Status: newassigned

comment:2 by Tim Graham, 9 years ago

Component: HTTP handlingForms
Patch needs improvement: set
Triage Stage: UnreviewedAccepted

The original purpose of this test is to check the case when Pillow doesn't detect the MIME type of the image, so we need to find a new case of that if possible.

comment:3 by Yosuke Yasuda, 9 years ago

Last edited 9 years ago by Yosuke Yasuda (previous) (diff)

in reply to:  2 comment:4 by Yosuke Yasuda, 9 years ago

Replying to timgraham:

The original purpose of this test is to check the case when Pillow doesn't detect the MIME type of the image, so we need to find a new case of that if possible.

Then, should I choose a different type of image which Pillow doesn't detect the MIME type? Or can I set file extension which doesn't exist?

I searched Pillow. I found that it is merging the code that detect MIME type.
https://github.com/python-pillow/Pillow/search?p=1&q=MIME&utf8=%E2%9C%93

So if I find an image type that Pillow doesn't detect now, the same kind of issue may happen later.

Last edited 9 years ago by Yosuke Yasuda (previous) (diff)

comment:5 by Yosuke Yasuda, 9 years ago

I found a tga file can be ImageFile and its MIME type is not detected, so I changed bmp to tga.

comment:6 by Andriy Sokolovskiy, 9 years ago

Yes, after previous ticket I added MIME for BMP, so it will fail.
I think it is better to use mock to model this situation instead of fixing every time after Pillow registers MIME for image plugin without it.

comment:7 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In a2b999d:

Fixed #25108 -- Fixed a test which failed on Pillow 2.9+

comment:8 by Tim Graham <timograham@…>, 9 years ago

In 269315d8:

[1.8.x] Fixed #25108 -- Fixed a test which failed on Pillow 2.9+

Backport of a2b999dfcac9bc92513a36ec6b3033ded1561c66 from master

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