Commit Graph

63 Commits

Author SHA1 Message Date
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
ccdea48cf3 Added identity tests for Transform classes 2024-01-08 10:36:30 +11:00
Andrew Murray
ba6399cad1 Added PerspectiveTransform 2024-01-07 19:34:27 +11:00
Hugo van Kemenade
43b2f61e79 Add 'from __future__ import annotations' using Ruff/isort 2023-12-21 13:13:31 +02:00
Yay295
04199b6066 sort colors before comparing them 2023-01-07 19:16:06 +11:00
Yay295
48b6d4fd60 remove no-format tags and fix comment locations 2023-01-07 19:16:06 +11:00
Yay295
09a7255ced
Apply suggestions from code review
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2022-08-29 11:35:06 -05:00
Yay295
a7f7f6ac05
parametrize tests 2022-08-24 07:43:49 -05:00
Andrew Murray
f8e4e9c2dd Added enums 2022-01-15 09:02:31 +11:00
Andrew Murray
d1815377b8 Copy palette to new image in transform() 2021-07-31 22:49:16 +10:00
Ondrej Baranovič
9872d57e3b
corrected comment 2021-03-27 02:06:36 +01:00
nulano
49fa3656b1 do not premultiply alpha when resizing with Image.NEAREST resampling 2021-03-23 13:16:20 +01:00
Hugo van Kemenade
dd87dd50c0 Update to isort 5 with Black profile support 2020-08-08 22:39:29 +03:00
Andrew Murray
7ff2db143d Removed use of PillowTestCase 2020-03-23 07:05:51 +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
Hugo van Kemenade
54e57768ab
Merge pull request #4128 from radarhere/info
Copy info in Image.transform
2019-11-13 20:27:51 +02:00
Andrew Murray
b65fcb280a Copy info in transform 2019-10-30 22:14:01 +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
77f946d8bc Format with Black 2019-06-13 18:54:24 +03:00
Andrew Murray
77630f000c Updated resampling filter error messages 2019-06-06 21:36:38 +10: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
Jon Dufresne
7da17ad41e Improve pytest configuration to allow specific tests as CLI args
The previous test configuration made it difficult to run a single test
with the pytest CLI. There were two major issues:

- The Tests directory was not a package. It now includes a __init__.py
  file and imports from other tests modules are done with relative
  imports.

- setup.cfg always specified the Tests directory. So even if a specific
  test were specified as a CLI arg, this configuration would also always
  include all tests. This configuration has been removed to allow
  specifying a single test on the command line.

Contributors can now run specific tests with a single command such as:

  $ tox -e py37 -- Tests/test_file_pdf.py::TestFilePdf.test_rgb

This makes it easy and faster to iterate on a single test failure and is
very familiar to those that have previously used tox and pytest.

When running tox or pytest with no arguments, they still discover and
runs all tests in the Tests directory.
2019-01-13 09:00:12 -08:00
Hugo
eb9aee7048 flake8: F841 local variable is assigned to but never used 2018-11-11 19:01:10 +02:00
Andrew Murray
ae2ffb8a05 Fixed transform fillcolor argument when image mode is RGBA or LA 2018-06-12 04:41:46 +10:00
Andrew Murray
cbc056f43d Fixed whitespace 2018-04-18 16:00:57 +10:00
Andrew Murray
c13ccf13a1 Added missing whitespace 2018-03-06 19:53:07 +11:00
Andrew Murray
2202196162 Flake8 blank line fixes 2018-03-04 21:36:33 +11:00
Eric Soroos
fa9e9c2795 remove duplicate test 2017-11-13 11:59:26 +00:00
Eric Soroos
52b6894865 parameter name change 2017-11-13 11:59:12 +00:00
wiredfool
dce04b680b Pass in fill color to transform. 2017-11-11 16:47:31 +00:00
Andrew Murray
9e843a2d9b Changed format of lambda calls 2017-09-01 21:05:40 +10:00
Andrew Murray
e67ee44ea8 Added test for missing method data in Image transform 2017-01-28 14:21:41 +11:00
Andrew Murray
5c59603fcf Fixed typos 2016-08-31 20:12:07 +10:00
homm
993e49c0be Merge branch 'master' into rotation-pixel-center 2016-08-07 13:47:16 +03:00
homm
5b8c8aa389 improve resize test 2016-07-11 00:47:58 +03:00
homm
1321713688 repeat all affine tests with PERSPECTIVE 2016-07-11 00:26:12 +03:00
homm
ad3f7238d2 add translate tests 2016-07-10 21:48:19 +03:00
homm
ac747d2290 resize transform tests 2016-07-10 16:09:33 +03:00
homm
2522101ed7 tests for 90 degree transformation 2016-07-10 15:23:01 +03:00
homm
1ba4e9e5ba remove end of file banner from all files 2016-07-10 14:11:28 +03:00
Andrew Murray
444d9d5731 Changed variable name foo since it has been blacklisted in health 2015-04-01 10:29:26 +11:00
homm
aabf66a7a4 fix tests: use im.transform directly when result is compared
with other transform operations.
2014-11-10 02:11:12 +03:00
hugovk
f10bdf7cd1 Fix test 2014-09-14 21:21:16 +03:00
hugovk
8dad2b0c63 Replace some lena() with hopper(), and temporarily disable fail-fast so we can see all failures 2014-09-05 13:03:56 +03:00
hugovk
15c92359cc Merge some similar tests to a single file 2014-07-20 01:17:32 +03:00
hugovk
cf04a9a0d2 Remove unused tearDownModule 2014-07-07 20:03:50 +03:00