Commit Graph

144 Commits

Author SHA1 Message Date
Andrew Murray
fdce845364 Added exception explaining that _repr_png_ saves to PNG 2020-12-27 15:36:16 +11:00
Hugo van Kemenade
a7f384a813
Merge pull request #4292 from radarhere/private_png_chunks
Added reading and writing of private PNG chunks
2020-10-05 23:49:09 +03:00
Hugo van Kemenade
fdc09206d0
Merge pull request #4828 from radarhere/exif_text 2020-08-11 21:52:12 +03:00
Hugo van Kemenade
dd87dd50c0 Update to isort 5 with Black profile support 2020-08-08 22:39:29 +03:00
Andrew Murray
5da1a8adcf Read EXIF data tEXt chunk into info as bytes instead of string 2020-07-31 17:42:48 +10:00
Jakub Kulík
ee856bdc25 Fix expected failures on big endian systems without CI 2020-07-16 11:04:16 +02:00
nulano
a324f4a466 add version to features info block 2020-06-21 18:58:39 +10:00
Andrew Murray
f21816918e Allow ImageMagick zTXt chunks to be extracted after copy() 2020-04-16 21:14:19 +10:00
Andrew Murray
1e63f772f8 Parse orientation from XMP tags 2020-04-16 21:05:34 +10:00
Hugo
dda6145fce Since Python 3.3 IOError and WindowsError have been merged into OSError 2020-04-10 12:57:29 +03:00
Andrew Murray
f7144c1216 Added reading and writing of private PNG chunks 2020-04-06 21:57:45 +10:00
Andrew Murray
7475c06b1c Assert that seeking too far raises an EOFError 2020-04-05 15:29:13 +10:00
Andrew Murray
6574552821 Removed redundant arguments 2020-04-02 19:17:54 +11:00
Hugo
2e9030ddca Initialise __frame = 0 in open, and test tell 2020-04-02 08:49:26 +03:00
Hugo
1c2b2b085a Add test case 2020-04-01 22:32:14 +03:00
Hugo van Kemenade
f27873a888
Merge pull request #4243 from pmrowla/apng
Add APNG support
2020-04-01 00:23:57 +03:00
Andrew Murray
d4b627b664 Parametrized test 2020-03-26 21:21:40 +11:00
Andrew Murray
ca5a81ef27 Added reading of earlier ImageMagick EXIF data 2020-03-14 00:04:58 +11:00
Andrew Murray
9f61be4c72
Merge branch 'master' into apng 2020-03-09 23:29:40 +11:00
Hugo
2cc6a9a974 Convert to use pytest 2020-03-02 16:31:08 +02:00
Hugo van Kemenade
64a9e0c660
Merge branch 'master' into apng 2020-02-29 17:40:17 +02:00
Andrew Murray
41a29339ff Lint fixes 2020-02-23 15:14:42 +11:00
Peter Rowlands
0f84fa7707 Move apng tests into test_file_apng.py 2020-02-23 15:14:06 +11:00
Peter Rowlands
00fcc53a1d Fix lint errors 2020-02-23 15:14:06 +11:00
Peter Rowlands
66c84f258b Add test for saving split fdat chunks 2020-02-23 15:14:06 +11:00
Peter Rowlands
7c0df1034f Add APNG test cases
Includes tests for reading and writing APNG files.

The tests for reading files are based on the APNG browser compatibility
tests from https://philip.html5.org/tests/apng/tests.html
(which is linked in the Tests section of https://wiki.mozilla.org/APNG_Specification)
2020-02-23 15:14:06 +11:00
Hugo
699a9dadf1 Convert asserts 2020-02-22 18:07:04 +02:00
Andrew Murray
8482919a37 Converted most assert statements to pytest 2020-02-23 00:06:21 +11:00
Jon Dufresne
4f185329f4 Streamline test skipping based on supported features
This adds a new test decorator: skip_unless_feature(). The argument is
the same as passed to features.check(). If the feature is not supported,
the test will be skipped.

This removes several kinds of boilerplate copied and pasted around tests
so test feature checking is handled and displayed more consistently.

Refs #4193
2020-02-18 13:07:01 -08:00
Hugo
38bf862185 Replace PillowTestCase.assert_warning with pytest.warns 2020-02-03 11:11:32 +02:00
Hugo
a4bf9fa036 Convert most PillowTestCase methods to pytest 2020-02-02 12:26:01 +02:00
Hugo
f96763826c Test on new Travis CPUs https://blog.travis-ci.com/2019-11-12-multi-cpu-architecture-ibm-power-ibm-z 2020-01-08 15:43:27 +02:00
Andrew Murray
c0048ad7de Use context managers 2019-11-26 07:03:23 +11:00
Jon Dufresne
33dabf986f Import unittest from stdlib rather than helper.py
The unittest in helper.py has not offered an interesting abstraction
since dbe9f85c7d so import from the more
typical stdlib location.
2019-11-20 18:42:52 -08:00
Hugo
cc63f66575 Merge remote-tracking branch 'upstream/master' into rm-2.7 2019-11-01 13:22:56 +02:00
Jon Dufresne
4cd4adddc3 Improve handling of file resources
Follow Python's file object semantics. User code is responsible for
closing resources (usually through a context manager) in a deterministic
way.

To achieve this, remove __del__ functions. These functions used to
closed open file handlers in an attempt to silence Python
ResourceWarnings. However, using __del__ has the following drawbacks:

- __del__ isn't called until the object's reference count reaches 0.
  Therefore, resource handlers remain open or in use longer than
  necessary.

- The __del__ method isn't guaranteed to execute on system exit. See the
  Python documentation:

  https://docs.python.org/3/reference/datamodel.html#object.__del__

  > It is not guaranteed that __del__() methods are called for objects
  > that still exist when the interpreter exits.

- Exceptions that occur inside __del__ are ignored instead of raised.
  This has the potential of hiding bugs. This is also in the Python
  documentation:

  > Warning: Due to the precarious circumstances under which __del__()
  > methods are invoked, exceptions that occur during their execution
  > are ignored, and a warning is printed to sys.stderr instead.

Instead, always close resource handlers when they are no longer in use.
This will close the file handler at a specified point in the user's code
and not wait until the interpreter chooses to. It is always guaranteed
to run. And, if an exception occurs while closing the file handler, the
bug will not be ignored.

Now, when code receives a ResourceWarning, it will highlight an area
that is mishandling resources. It should not simply be silenced, but
fixed by closing resources with a context manager.

All warnings that were emitted during tests have been cleaned up. To
enable warnings, I passed the `-Wa` CLI option to Python. This exposed
some mishandling of resources in ImageFile.__init__() and
SpiderImagePlugin.loadImageSeries(), they too were fixed.
2019-10-12 08:27:17 -07:00
Andrew Murray
4140cd807b
Merge branch 'master' into rm-2.7 2019-10-12 18:03:58 +11:00
Hugo
865b17d5cf Remove Python 2-compatibility code 2019-10-07 16:23:22 +03:00
Hugo
af770a6c55 Drop support for EOL Python 2.7 2019-10-07 14:30:59 +03:00
nulano
cf1f8b0498 Tests.helper cleanup 2019-09-25 11:58:02 +02:00
Jon Dufresne
d50445ff30 Introduce isort to automate import ordering and formatting
Similar to the recent adoption of Black. isort is a Python utility to
sort imports alphabetically and automatically separate into sections. By
using isort, contributors can quickly and automatically conform to the
projects style without thinking. Just let the tool do it.

Uses the configuration recommended by the Black to avoid conflicts of
style.

Rewrite TestImageQt.test_deprecated to no rely on import order.
2019-07-06 16:11:35 -07:00
Hugo
f87821e010 Format with Black 2019-06-13 18:54:11 +03:00
Andrew Murray
231fe4d62a Revert "Merge pull request #3838 from radarhere/i_conversion"
This reverts commit 41f3e7c8bd, reversing
changes made to 2f84482871.
2019-06-11 19:28:31 +10:00
Andrew Murray
8a035b8c5d Improved I mode conversion 2019-05-08 21:58:33 +10:00
Andrew Murray
c96cdb5e77 Consistent DPI rounding 2019-03-30 15:03:57 +11:00
Andrew Murray
4a5666f1f4 Added transparency for all PNG greyscale modes 2019-03-27 07:41:33 +11:00
Andrew Murray
ce9dd67540 Added I;16 PNG save 2019-03-12 17:28:42 +11:00
Andrew Murray
8ddcc1de52 Load EXIF from PNG where eXIf chunk is after first IDAT chunk 2019-03-11 21:20:18 +11:00
Andrew Murray
365d5e541a Added EXIF support 2019-03-11 21:19:36 +11:00
Jon Dufresne
4de5477b61 Remove unnecessary unittest.main() boilerplate from test files
With the introduction and use of pytest, it is simple and easy to
execute specific tests in isolation through documented command line
arguments. Either by specifying the module path or through the `-k
EXPRESSION` argument. There is no longer any need to provide the
boilerplate:

    if __name__ == '__main__':
        unittest.main()

To every test file. It is simply noise.

The pattern remains in test files that aren't named with `test_*` as
those files are not discovered and executed by pytest by default.
2019-02-03 10:10:16 -08:00