Commit Graph

84 Commits

Author SHA1 Message Date
Andrew Murray
6883018725 Added type hint 2024-07-06 22:06:47 +10:00
Andrew Murray
486dac7efc Added type hints 2024-07-06 19:17:23 +10:00
Hugo van Kemenade
51bd7d2ea8
Drop support for Python 3.8 (#8183)
Co-authored-by: Andrew Murray <radarhere@users.noreply.github.com>
Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
2024-07-03 00:44:45 -06:00
Andrew Murray
5ff7d926fd Added type hints 2024-02-17 15:00:38 +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
Hugo van Kemenade
43b2f61e79 Add 'from __future__ import annotations' using Ruff/isort 2023-12-21 13:13:31 +02:00
Andrew Murray
73bd40babe Test for relevant characters before and after "SMask" 2023-08-07 20:49:29 +10:00
Andrew Murray
a70ea82eb5 Write P transparency as SMask 2023-08-07 13:53:19 +10:00
Andrew Murray
0a0a3fc51f Added saving LA images as PDFs 2023-07-22 20:16:45 +10:00
Andrew Murray
36ee817329 Merge branch 'main' into pdf 2023-03-12 23:31:26 +11:00
Andrew Murray
be489287d2 Parametrized test 2023-02-23 12:44:38 +01:00
Jasper van der Neut
36bcc0a898 Support saving PDF with different X and Y resolution.
Add a `dpi` parameter to the PDF save function, which accepts
a tuple with X and Y dpi.
This is useful for converting tiffg3 (fax) images to pdf,
which have split dpi like (204,391), (204,196) or (204,98).
2023-02-21 11:49:05 +01: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
642d574087 Added JPXDecode for RGBA images 2023-02-02 21:48:47 +11:00
Andrew Murray
2803304763 Skip timeout checks on slower running valgrind job 2022-12-31 13:47:07 +11:00
Andrew Murray
fa71b11073 Revert "Temporarily skip valgrind failure"
This reverts commit a3e61c1f89.
2022-10-29 12:02:07 +03:00
Andrew Murray
c259ac492f Parametrized tests 2022-10-03 16:57:42 +11:00
Hugo van Kemenade
b953f73548
Merge pull request #6518 from radarhere/pdf_ccittfaxdecode 2022-08-31 13:55:46 +03:00
Andrew Murray
a3e61c1f89 Temporarily skip valgrind failure 2022-08-23 09:16:40 +10:00
Andrew Murray
3b4ea7c602 Do not use CCITTFaxDecode filter if libtiff is not available 2022-08-22 19:57:33 +10:00
Andrew Murray
f5b27f90f7 Save 1 mode PDF using CCITTFaxDecode filter 2022-08-01 20:38:47 +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
Hugo van Kemenade
dd8049363e Use more specific regex chars to prevent ReDoS - exclude carriage return 2021-12-28 10:22:39 +11:00
Andrew Murray
bc935f9970 Do not round dimensions when saving PDF 2021-05-01 12:13:09 +10:00
Andrew Murray
d62be3e354 Switched to saving 1-bit PDFs with DCTDecode 2021-04-22 22:16:21 +10:00
wiredfool
fe668716ed
Merge pull request #5397 from wiredfool/valgrind_fixes
Valgrind fixes
2021-04-10 19:15:17 +01:00
Eric Soroos
1c872a9eda lint stuff 2021-04-10 16:58:01 +02:00
Eric Soroos
a3a69c8385 conditional mark for valgrind ignore 2021-04-09 23:53:24 +02:00
Hugo van Kemenade
bde149be38 Add test for CVE-2021-25292 ReDoS 2021-04-08 23:53:22 +03:00
Eric Soroos
a6fa139f62 useless reptile 2021-01-07 14:57:49 +01:00
Eric Soroos
1d7c8e03d0 known failing tests from valgrind -- uninitialized values 2021-01-07 14:52:02 +01: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
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
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
3a34081db5 Simplify temporary directory cleanup
Co-Authored-By: Jon Dufresne <jon.dufresne@gmail.com>
2019-10-08 17:25:55 +03:00
Hugo
538d9e2e5d Upgrade Python syntax with pyupgrade --py3-plus 2019-10-07 14:30:59 +03: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
ae1f7c4f50 Fixed dimensions of 1-bit PDFs 2019-05-04 16:27:34 +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
Andrew Murray
fc57658635 Added PDF creation and modification date info 2018-08-25 00:58:49 +10:00
Andrew Murray
c2189235af Line too long 2018-07-02 19:26:02 +10:00
Andrew Murray
3bbd0a5810 Fixed saving a multiframe image as a single frame PDF 2018-05-18 22:15:45 +10:00