Commit Graph

33 Commits

Author SHA1 Message Date
Andrew Murray
f26b47595b Get IPTC info from tag_v2 2024-08-19 06:56:31 +10:00
Andrew Murray
046285ac5d Added type hints 2024-07-26 16:42:28 +10: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
3ef7b93846
Merge branch 'main' into iptc 2024-01-01 15:23:08 +11:00
Nulano
fa4b3776f0 deprecate IptcImagePlugin.{dump,i,PAD} 2023-12-31 17:41:13 +02:00
Ondrej Baranovič
b1e88ac17f
omit default color value
Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
2023-12-31 14:49:48 +01:00
Nulano
46a6ddf0c2 fix loading IPTC images and add test 2023-12-31 13:53:09 +01:00
Andrew Murray
1d9c931626 Changed tile tuple to match other plugins 2023-12-31 22:43:08 +11:00
Hugo van Kemenade
43b2f61e79 Add 'from __future__ import annotations' using Ruff/isort 2023-12-21 13:13:31 +02:00
Hugo van Kemenade
5eea6ed633 Replace 'assert False' with pytest.fail() 2023-11-12 22:30:28 +02:00
Andrew Murray
b37ca350a8 Allow FotoStation tags 2023-08-22 10:13:41 +10:00
Andrew Murray
6bd3ed439a Ignore IPTC field that is only zero bytes 2023-08-04 23:54:48 +10: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
7fd9663198 Convert various tests to pytest style 2020-01-27 22:46:52 +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
af770a6c55 Drop support for EOL Python 2.7 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
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
257bc8bd4f Added tests 2017-03-03 19:45:55 +11:00
homm
1ba4e9e5ba remove end of file banner from all files 2016-07-10 14:11:28 +03:00
Andrew Murray
ecd4d5a186 Removed unused test helper 2016-04-17 23:27:09 +10:00
Andrew Murray
3c7e37d2d7 Replaced old-style classes 2015-05-27 00:07:21 +10:00
hugovk
b929873a62 Change some lena() to hopper() 2014-09-05 12:36:24 +03:00
hugovk
805184fcbb Fi xffor Python 3 2014-08-01 12:11:03 +03:00
hugovk
35838da803 Test dump() 2014-08-01 11:56:21 +03:00
hugovk
a0aff1a87f Remove disabled _is_raw() 2014-08-01 11:12:47 +03:00
hugovk
f5440cc3e1 Fixes for Python 3 2014-07-30 20:43:34 +03:00
hugovk
4c5a5c1f0e Tests for IptcImagePlugin.py 2014-07-30 19:34:20 +03:00