Commit Graph

118 Commits

Author SHA1 Message Date
Andrew Murray
42381aa1e6 Added type hints 2024-06-24 06:59:00 +10:00
Andrew Murray
904b8e549c Allow writing IFDRational to UNDEFINED tag 2024-02-28 21:07:15 +11:00
Andrew Murray
e39765d755 Added type hints 2024-02-20 15:41:20 +11:00
Hugo van Kemenade
4a4b90c365
Autotype tests (#7756)
* autotyping: --none-return
* autotyping: --scalar-return
* autotyping: --int-param
* autotyping: --float-param
* autotyping: --str-param
* autotyping: --annotate-named-param tmp_path:pathlib.Path
2024-01-31 20:12:58 +11:00
Hugo van Kemenade
53c3cd9f8e isort Tests 2024-01-20 13:23:03 +02:00
Andrew Murray
99760f4c59
Merge branch 'main' into tiff 2024-01-01 13:41:17 +11:00
Andrew Murray
f7ec665bf1 Support setting ROWSPERSTRIP tag 2023-12-29 23:00:14 +11:00
Andrew Murray
f6bcf4e1ae Use IMAGEWIDTH and IMAGELENGTH when calculating strip size 2023-12-29 14:15:40 +11:00
Hugo van Kemenade
43b2f61e79 Add 'from __future__ import annotations' using Ruff/isort 2023-12-21 13:13:31 +02:00
Andrew Murray
1263018d2a Assert value instead of assigning unused variable 2023-02-24 21:01:03 +02:00
Aarni Koskela
43128ce716 Fix up pytest.warns lambda: uses 2023-02-23 16:06:40 +02:00
Andrew Murray
ad0e9dbaaf Fixed writing int as UNDEFINED tag 2023-02-14 10:52:32 +11:00
pre-commit-ci[bot]
24183d652e [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2023-02-06 19:27:19 +00:00
Andrew Murray
e48aead015 Allow writing IFDRational to BYTE tag 2023-01-13 21:02:42 +11:00
Andrew Murray
0da8e43977 Parametrized test 2022-12-29 08:58:38 +11:00
Andrew Murray
6da4169f37 Fixed writing int as ASCII tag 2022-12-13 22:40:55 +11:00
Andrew Murray
70cc8a5741 Fixed writing int as BYTE tag 2022-11-15 09:06:41 +11:00
Andrew Murray
3459120732 Fixed writing bytes as ASCII tag 2022-08-11 20:46:58 +10:00
Hugo van Kemenade
a715bf2d6f [Test] function name should be snake_case 2022-04-11 15:29:01 +03:00
Hugo van Kemenade
d3c9a6504e Variable in function should be snake_case 2022-04-10 23:55:16 +03:00
Andrew Murray
72b7ab54bd pre-commit autoupdate --freeze 2022-03-04 16:42:24 +11:00
Andrew Murray
98aa0f10ad pre-commit autoupdate --freeze 2021-08-12 21:50:09 +10:00
Andrew Murray
dd28af0dfa
Merge branch 'master' into tag_group_data 2021-06-27 12:06:11 +10:00
Andrew Murray
61c39074f5 Fixed undefined variable in logging 2021-06-25 19:46:58 +10:00
Andrew Murray
a2709be7f4 Added tag data for IFD groups 2021-06-24 19:56:01 +10:00
Andrew Murray
976d9fa347 Fixed UNDEFINED TIFF tag of length 0 being changed in roundtrip 2021-04-29 21:21:09 +10:00
Andrew Murray
6b098a2c34 Changed TIFF tag 33723 length to 1 2021-04-21 22:37:47 +10:00
Hugo van Kemenade
e0eec1eb56 Merge branch 'master' into rm-3.5 2020-09-01 20:16:46 +03:00
Hugo van Kemenade
10615a7da7 Upgrade Python syntax for 3.6+
Co-authored-by: nulano <nulano@nulano.eu>
2020-07-30 10:09:18 +03:00
Andrew Murray
8383e840e4
Merge pull request #4626 from radarhere/stripbytecounts
Change STRIPBYTECOUNTS to LONG if necessary when saving
2020-06-21 09:02:56 +10:00
Andrew Murray
7ecb5aaf7e BYTE tags of variable length are only single strings 2020-06-10 16:09:22 +10:00
Andrew Murray
b3604167ad Change STRIPBYTECOUNTS to LONG if necessary when saving 2020-05-15 20:47:57 +10:00
Andrew Murray
09b9198176 Converted to pytest 2020-02-25 20:57:27 +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
Hugo van Kemenade
098406c304
Merge pull request #4390 from jdufresne/resource-warning
Fix ResourceWarning emitted during tests
2020-02-12 17:10:51 +02: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
Jon Dufresne
2b84221edf Fix ResourceWarning emitted during tests
Appeared in the form:

    ResourceWarning: unclosed file <_io.BufferedReader name='Tests/images/invalid-exif-without-x-resolution.jpg'>

Enable all warnings to always display during tests to help catch these
warnings earlier.
2020-01-26 16:00:46 -08:00
Andrew Murray
8924054dd9 Changed _limit_signed_rational 2019-12-31 19:12:33 +11:00
Andrew Murray
69fc041399 Test out of bounds signed rational 2019-12-31 19:11:03 +11:00
Andrew Murray
74d53bcd15 Lint fixes 2019-12-31 11:58:39 +11:00
Andrew Murray
6d3fb7b083
Merge branch 'master' into exif-writing-fixes 2019-12-31 11:38:33 +11:00
Andrew Murray
c0048ad7de Use context managers 2019-11-26 07:03:23 +11: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
Hugo
538d9e2e5d Upgrade Python syntax with pyupgrade --py3-plus 2019-10-07 14:30:59 +03:00
Hugo van Kemenade
572a93c86f
Corrected tag counts (#4033)
Corrected tag counts
2019-09-05 22:41:16 +03:00
Konstantin Kopachev
06e34db10b
Merge remote-tracking branch 'upstream/master' into exif-writing-fixes
# Conflicts:
#	Tests/test_file_tiff_metadata.py
2019-08-29 09:20:09 -07:00
Andrew Murray
ddcfd259cf Corrected short and long range checks 2019-08-29 19:36:46 +10:00