Commit Graph

26 Commits

Author SHA1 Message Date
Yay295
0d86da54bc
add typing to "ims" in test_image_fromqimage.py
Co-authored-by: Ondrej Baranovič <ondreko.tiba@gmail.com>
2024-03-27 14:02:02 -05:00
pre-commit-ci[bot]
26a212126f [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2024-03-27 15:57:36 +00:00
Yay295
9c6b30560e use setup_module() to open images so they aren't opened if skipped 2024-03-27 10:53:07 -05:00
Andrew Murray
6d78d42769 Added type hints 2024-03-02 13:12:17 +11:00
Andrew Murray
ddb7df0ec6 Added type hints 2024-01-25 22:18:46 +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
Hugo van Kemenade
f854d7f7c9 Deprecate support for Qt 5 (PyQt5 and PySide2). Use Qt 6 (PyQt6 or PySide6) instead. 2022-04-22 15:56:11 +03:00
Hugo van Kemenade
dd87dd50c0 Update to isort 5 with Black profile support 2020-08-08 22:39:29 +03:00
Andrew Murray
b602f365ae Removed PillowTestCase helper class 2020-03-28 12:51:28 +11:00
Andrew Murray
a8637449b9 Converted common Qt test classes 2020-03-28 12:21:00 +11:00
Andrew Murray
748739c992 Converted addCleanup 2020-03-28 12:20:56 +11:00
Hugo
a4bf9fa036 Convert most PillowTestCase methods to pytest 2020-02-02 12:26:01 +02:00
Hugo
b4f93cf140 Upgrade Python syntax with pyupgrade --py3-plus 2019-11-01 13:54:19 +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
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
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
homm
1ba4e9e5ba remove end of file banner from all files 2016-07-10 14:11:28 +03:00
Andrew Murray
c27110ab56 Flake8 fixes 2015-12-10 21:34:02 +11:00
Eric L Frederich
e67a4c4270 preserve alpha during conversion; add tests; found bug and added TODOs 2015-09-18 16:15:24 -04:00
Eric L Frederich
86e775daa3 bug fix: Qt wants data aligned to 32 bits
Images in Qt show up incorrectly if each line is not aligned to 32 bits.

It is pretty common for an image's lines to be 32-bit alinged by chance.
Obviously any 32-bit image will not have any problem.
For the bug to manifest itself you'd need...
* a 1-bit image whose width is not a multiple of 32
* an 8-bit image who width is not a multiple of 4

Testing more images now and added a 7x13 png test image
2015-09-18 16:07:35 -04:00
Andrew Murray
43e2c92802 Removed unused imports 2015-06-19 15:35:56 +10:00
Roman Inflianskas
854d343aa5 add functions to convert: Image <-> QImage; Image <-> QPixmap (see #897); fix typo that breaks tests 2015-06-18 11:21:14 +10:00
Roman Inflianskas
2d706d74dc add functions to convert: Image <-> QImage; Image <-> QPixmap (see #897) 2015-06-18 11:21:14 +10:00