Commit Graph

100 Commits

Author SHA1 Message Date
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
Andrew Murray
72b7ab54bd pre-commit autoupdate --freeze 2022-03-04 16:42:24 +11:00
Andrew Murray
98aa0f10ad pre-commit autoupdate --freeze 2021-08-12 21:50:09 +10:00
Andrew Murray
dd28af0dfa
Merge branch 'master' into tag_group_data 2021-06-27 12:06:11 +10:00
Andrew Murray
61c39074f5 Fixed undefined variable in logging 2021-06-25 19:46:58 +10:00
Andrew Murray
a2709be7f4 Added tag data for IFD groups 2021-06-24 19:56:01 +10:00
Andrew Murray
976d9fa347 Fixed UNDEFINED TIFF tag of length 0 being changed in roundtrip 2021-04-29 21:21:09 +10:00
Andrew Murray
6b098a2c34 Changed TIFF tag 33723 length to 1 2021-04-21 22:37:47 +10:00
Hugo van Kemenade
e0eec1eb56 Merge branch 'master' into rm-3.5 2020-09-01 20:16:46 +03:00
Hugo van Kemenade
10615a7da7 Upgrade Python syntax for 3.6+
Co-authored-by: nulano <nulano@nulano.eu>
2020-07-30 10:09:18 +03:00
Andrew Murray
8383e840e4
Merge pull request #4626 from radarhere/stripbytecounts
Change STRIPBYTECOUNTS to LONG if necessary when saving
2020-06-21 09:02:56 +10:00
Andrew Murray
7ecb5aaf7e BYTE tags of variable length are only single strings 2020-06-10 16:09:22 +10:00
Andrew Murray
b3604167ad Change STRIPBYTECOUNTS to LONG if necessary when saving 2020-05-15 20:47:57 +10:00
Andrew Murray
09b9198176 Converted to pytest 2020-02-25 20:57:27 +11:00
Hugo
699a9dadf1 Convert asserts 2020-02-22 18:07:04 +02:00
Andrew Murray
8482919a37 Converted most assert statements to pytest 2020-02-23 00:06:21 +11:00
Hugo van Kemenade
098406c304
Merge pull request #4390 from jdufresne/resource-warning
Fix ResourceWarning emitted during tests
2020-02-12 17:10:51 +02:00
Hugo
38bf862185 Replace PillowTestCase.assert_warning with pytest.warns 2020-02-03 11:11:32 +02:00
Hugo
a4bf9fa036 Convert most PillowTestCase methods to pytest 2020-02-02 12:26:01 +02:00
Jon Dufresne
2b84221edf Fix ResourceWarning emitted during tests
Appeared in the form:

    ResourceWarning: unclosed file <_io.BufferedReader name='Tests/images/invalid-exif-without-x-resolution.jpg'>

Enable all warnings to always display during tests to help catch these
warnings earlier.
2020-01-26 16:00:46 -08:00
Andrew Murray
8924054dd9 Changed _limit_signed_rational 2019-12-31 19:12:33 +11:00
Andrew Murray
69fc041399 Test out of bounds signed rational 2019-12-31 19:11:03 +11:00
Andrew Murray
74d53bcd15 Lint fixes 2019-12-31 11:58:39 +11:00
Andrew Murray
6d3fb7b083
Merge branch 'master' into exif-writing-fixes 2019-12-31 11:38:33 +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
538d9e2e5d Upgrade Python syntax with pyupgrade --py3-plus 2019-10-07 14:30:59 +03:00
Hugo van Kemenade
572a93c86f
Corrected tag counts (#4033)
Corrected tag counts
2019-09-05 22:41:16 +03:00
Konstantin Kopachev
06e34db10b
Merge remote-tracking branch 'upstream/master' into exif-writing-fixes
# Conflicts:
#	Tests/test_file_tiff_metadata.py
2019-08-29 09:20:09 -07:00
Andrew Murray
ddcfd259cf Corrected short and long range checks 2019-08-29 19:36:46 +10:00
Andrew Murray
35a7d11f43 Fixed typo [ci skip] 2019-08-29 19:02:19 +10:00
Andrew Murray
f08a0966a0 Corrected tag counts 2019-08-19 21:12:16 +10:00
Konstantin Kopachev
1b626f4d22 Fix RATIONAL and SRATIONAL boundaries when writing IFDs 2019-08-12 19:43:35 +10: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
990fb03218 Changed if to elif 2018-11-12 06:14:04 +11:00
Hugo
088d04470e Unnecessary list comprehension - 'tuple' can take a generator 2018-10-24 22:29:56 +03:00
Andrew Murray
a8261a2e89 Line too long 2018-09-27 20:35:00 +10:00
Jon Dufresne
875e8c4bda Avoid catching unexpected exceptions in tests
Instead, allow exceptions to bubble up to the unittest exception
handler.

Prevents replacing the exception trace with a less informative
message. As the exceptions are always unexpected, should not need to
catch them explicitly in tests.
2018-09-04 19:43:20 -07: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
Metallicow
5e94cd0fc2 Trim trailing whitespace tests dir 2018-01-27 00:07:24 -06:00
Eric Soroos
c12b9fb4dc added test for metadata count warning 2017-09-19 10:35:14 +00:00
Eric Soroos
56e490fe7c Test for issue #2278 2017-09-14 20:05:13 +01:00
Eric Soroos
843f8b2a6b Test for ImageJMetaDataByteCounts, #2006 2017-09-14 20:05:13 +01:00
Eric Soroos
83c57a8063 Specific change for issue #2006, ImageJ Metadata counts are incorrect in TiffTags 2017-09-14 20:05:13 +01:00