Commit Graph

71 Commits

Author SHA1 Message Date
Andrew Murray
882a196a8f Removed unused ignores 2024-07-20 18:59:27 +10:00
Andrew Murray
42381aa1e6 Added type hints 2024-06-24 06:59:00 +10:00
Andrew Murray
cc83cc8ec8 Updated type hints 2024-06-22 10:09:11 +10:00
Andrew Murray
3ba8eb3b7e Raise a ValueError for negative values when loading P1-P3 PPM images 2024-03-16 12:29:21 +11:00
Andrew Murray
d6a3f89e27 Open 16-bit grayscale PNGs as I;16 2024-03-02 15:39:43 +11:00
Andrew Murray
bb1fece57a Added type hints 2024-01-31 21:55:32 +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
Nulano
5dd1652f27 use filename instead of f 2024-01-08 17:17:52 +01:00
Nulano
0d841aab9a add support for grayscale pfm image format 2024-01-06 14:08:51 +01:00
Hugo van Kemenade
43b2f61e79 Add 'from __future__ import annotations' using Ruff/isort 2023-12-21 13:13:31 +02:00
Andrew Murray
5932a0bd19 Clear half token after use 2023-04-01 09:23:57 +11:00
Andrew Murray
64e5baaaf1 Write in binary format 2022-10-23 15:17:54 +11:00
pre-commit-ci[bot]
c93413835d [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2022-10-13 02:22:53 +00:00
Mark Mayo
69baeccf2e some pylint warnings
Fixed some pylint issues
2022-10-13 15:20:11 +13:00
Andrew Murray
6eb6232f04 Test comment that ends in the same block 2022-06-14 21:39:55 +10:00
Andrew Murray
216cd374dd Parametrized tests 2022-06-14 21:39:26 +10:00
Andrew Murray
c4d51fb268 Added support for PPM arbitrary maxval in plain formats 2022-06-13 19:55:25 +10:00
Andrew Murray
5051a29a4e Merge branch 'main' into plainPPM 2022-06-12 16:11:17 +10:00
Hugo van Kemenade
87c2373265
Merge pull request #6242 from radarhere/ppm_maxval 2022-05-01 21:21:52 +03:00
Andrew Murray
81b473f9d2 Raise ValueError for invalid maxval 2022-04-30 10:37:50 +10:00
Andrew Murray
5867e0bbac Decode bytes before passing to f-string 2022-04-24 15:42:45 +10:00
Andrew Murray
55be0ae6f4 Parametrized test 2022-03-14 08:07:13 +11:00
Andrew Murray
073acd4c82 Moved decoder names out of MODES 2022-03-12 17:32:15 +11:00
Andrew Murray
4283a604c0 Added support for arbitrary maxval 2022-03-09 22:29:45 +11:00
pre-commit-ci[bot]
0215175e1d [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2022-03-06 02:39:09 +00:00
Andrew Murray
97982cf703 Replaced assert_image_equal with assert_image_equal_tofile 2022-03-04 17:09:33 +11:00
Andrew Murray
7aa7d850ee Added context managers 2022-03-04 17:08:10 +11:00
Piolie
c1744e8536 Add tests for plain PPM 2022-03-04 17:03:07 +11:00
Andrew Murray
d96830115f Updated tests 2022-03-04 15:22:41 +11:00
Andrew Murray
65edcc4f77 Merge branch 'main' into PPMheaders 2022-03-04 12:30:41 +11:00
Andrew Murray
1b397751ec
Added context managers 2021-08-24 23:43:38 +10:00
Yutao Yuan
0f11d22cce Add tests for saving to stdout 2021-08-10 19:12:20 +08:00
Piolie
8ad5172e88 Fix wrong extension in temp test files 2021-03-21 02:16:39 -03:00
Andrew Murray
41a439da7d Added context managers 2021-03-21 14:42:36 +11:00
Andrew Murray
a5c251029c Replaced various instances of assert_image_equal with assert_image_equal_tofile 2021-02-21 22:15:56 +11:00
Andrew Murray
83542c42bf Added context managers 2021-02-11 21:43:54 +11:00
Piolie
bc5ecfb79c Make minor changes to tests
- add test for maxcolors;
- extend coverage for wrong magic number;
- fix linting.
2021-01-06 14:53:30 -03:00
Piolie
002e0bd697 Add tests for token size and wrong magic number 2021-01-06 01:21:35 -03:00
Piolie
5d0ad5e2e9 Revert exception types to ValueError 2021-01-06 01:21:01 -03:00
Piolie
699afe1e89 Improve PPM tests 2020-12-21 22:39:32 -03:00
Hugo van Kemenade
dd87dd50c0 Update to isort 5 with Black profile support 2020-08-08 22:39:29 +03: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
09b9198176 Converted to pytest 2020-02-25 20:57:27 +11:00
Andrew Murray
8482919a37 Converted most assert statements to pytest 2020-02-23 00:06:21 +11:00
Hugo
a4bf9fa036 Convert most PillowTestCase methods to pytest 2020-02-02 12:26:01 +02:00
Andrew Murray
c0048ad7de Use context managers 2019-11-26 07:03:23 +11: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
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