Django

Code

Ticket #7727 (closed: fixed)

Opened 5 months ago

Last modified 4 months ago

Obscure failure if PIL is not there

Reported by: fijal Assigned to: nobody
Milestone: 1.0 beta Component: Forms
Version: SVN Keywords:
Cc: fijall@gmail.com Triage Stage: Accepted
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

model_forms tests fail with obscure doctest errors when PIL is not there. Instead of saying "PIL not here" it will happily explode on you with "expected True got False". I'm not sure what's the way to skip doctests, but this is troublesome even for someone who does not run tests.

Attachments

Change History

07/13/08 02:21:27 changed by fijal

  • cc set to fijall@gmail.com.
  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

07/13/08 06:35:07 changed by russellm

  • stage changed from Unreviewed to Accepted.

The way to skip doctests is to break the sensitive doctest string into a separate string, and only concatenate the extra string onto the actual test string if PIL is available. The fixtures modeltest gives an example for a doctest that doesn't run under MySQL; an analogous approach should work for PIL.

07/20/08 01:03:50 changed by russellm

  • status changed from new to closed.
  • resolution set to worksforme.
  • milestone set to 1.0 beta.

When I disable PIL, I don't get any failures. Looking at the code, if PIL is missing, the test should revert to a simple FileField? test. Can you clarify (1) which test is failing, and (2) what other test conditions could be causing the failure.

07/21/08 05:23:34 changed by fijal

  • status changed from closed to reopened.
  • resolution deleted.

Wrong specification. If PIL is there, but _imaging is not there. This is the case ie. on top of pypy, where pure python module can be imported, but C extension cannot. It raises ImportError?, but newforms/fields.py#509 catches all exceptions and raises ValidationErrors? instead of reporting correctly that PIL is broken.

07/21/08 07:04:26 changed by russellm

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

(In [8016]) Fixed #7727 -- Improved the checks for import failure when using PIL. Under PyPy, you can import the PIL module, but when you try to use it, the underlying _imaging module will not be available. Thanks to Maciej Fijalkowski (fijal) for the report and suggested fix.


Add/Change #7727 (Obscure failure if PIL is not there)




Change Properties
Action