Commit Graph

158 Commits

Author SHA1 Message Date
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
Hugo
1885a2cef5
Merge pull request #3579 from jdufresne/run-one-test
Improve pytest configuration to allow specific tests as CLI args
2019-02-03 11:30:57 +02:00
Hugo
187ba3f6e8 Flake8: Fix F723 syntax error in type comment 'dummy value'; it's just a comment, not a Mypy type 2019-01-30 11:53:26 +02: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
Jon Dufresne
3e28ba3b7d Python del is a statement not a function
https://docs.python.org/3/reference/simple_stmts.html#the-del-statement
2019-01-12 18:28:35 -08:00
Andrew Murray
6ead422e91 Added custom string TIFF tags 2018-12-29 16:14:52 +11:00
Konstantin Kopachev
e91b851fdc
Add reading old-JPEG compressed TIFFs
Old-style JPEG compression in TIFFs are able to be read using Strip/Tile APIs. Although, it should be possible to read them using Scanline API, it does not work for some reason.  Anyway, reading subsampled YCbCr formats through Strip/Tile/Scanline libtiff API does not de-subsample the data, so caller should unpack data to whatever format is appropriate.  New-style JPEG compressed images were already read through libtiff as RGB images (https://github.com/python-pillow/Pillow/pull/3227). Unfortunately, there is no flag to ask libtiff to de-subsample old jpeg, but it provides a way to read any image as 32bit RGBA.  This commit adds ability to read old-style JPEG TIFFs through reading *all* YCbCr images as RGBX using Tile and Strip reading API. This supersedes previous work (PR #3227) to read new-style JPEG-TIFFs.
2018-12-10 10:07:41 -08:00
Andrew Murray
ddf8593e7b Do not write custom tags with libtiff < 4 2018-11-12 06:14:04 +11:00
Andrew Murray
a3d45e9cef Added custom int and float TIFF tags 2018-11-12 06:14:04 +11:00
Hugo
a3b0659790 flake8 2018-10-24 22:29:01 +03:00
Hugo
d1ca4916e0 Use more specific assertions 2018-10-24 22:29:01 +03:00
Andrew Murray
c7d924fd85 Too many blank lines 2018-10-21 18:11:50 +11:00
Hugo
d36365f4fb
Merge pull request #3227 from kkopachev/master
Adding support to reading tiled and YcbCr jpeg tiffs through libtiff
2018-09-29 19:45:29 +03:00
Hugo
84b4905a94
Merge pull request #3310 from radarhere/compression
Fixed None as TIFF compression argument
2018-09-29 19:44:43 +03:00
Hugo
b9b4c03957
Merge pull request #2203 from jdufresne/test-exceptions
Avoid catching unexpected exceptions in tests
2018-09-26 15:43:41 +03:00
Konstantin Kopachev
b0e5e5fb11
Update test files to be closer match of originals 2018-09-18 12:05:51 -07:00
Konstantin Kopachev
52637a4268
move libtiff-related tests into libtiff test file 2018-09-18 12:05:50 -07:00
wiredfool
4cfcc3b010 Tests for issue #1765 2018-09-07 20:32:54 +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
36b1afff26 Fixed None as TIFF compression argument 2018-08-25 08:21:43 +10:00
Andrew Murray
c2189235af Line too long 2018-07-02 19:26:02 +10:00
Andrew Murray
0e61d4be9f Removed unused variables 2018-07-02 19:21:44 +10:00
Andrew Murray
dcf6bc047b Do not use bare except 2018-07-02 19:21:44 +10:00
Andrew Murray
b4e6cdadac Added py3 variable to _util 2018-04-20 09:19:13 +10:00
Eric Soroos
768668c1d7 Added RGB*;16N Unpackers 2017-12-20 13:53:14 +00:00
Eric Soroos
e617d05b9e These tests/features now require libtiff 2017-12-20 12:22:28 +00:00
Eric Soroos
4b4f7d6a2c Refactor to use features 2017-12-20 12:21:33 +00:00
Eric Soroos
d698d522ef Added end to end tests in test_file_libtiff 2017-12-20 12:09:26 +00:00
Andrew Murray
9e843a2d9b Changed format of lambda calls 2017-09-01 21:05:40 +10:00
wiredfool
c16ba722f2 Merge pull request #2551 from jdufresne/keys
Remove unnecessary calls to dict.keys()
2017-06-13 13:12:48 +01:00
Andrew Murray
e8cba27bb1 Changed assert checks to more specific versions 2017-06-03 14:04:54 +10:00
Jon Dufresne
d244fbb299 Remove unnecessary calls to dict.keys()
iter(dict) is equivalent to iter(dict.keys()), so simply act on the dict
instead of adding the extra call.

Inspired by Lennart Regebro's PyCon 2017 presentation "Prehistoric
Patterns in Python". Available at:

https://www.youtube.com/watch?v=V5-JH23Vk0I
2017-05-28 09:55:38 -07:00
Andrew Murray
37b293f593 Flake8 fixes 2017-04-20 21:14:23 +10:00
Marcus Brinkmann
5bdf1e4998 Test for libtiff, n_frames and seek. 2017-03-14 23:17:22 +00:00
Andrew Murray
1fcdf6a2db Removed duplicate test 2017-03-03 21:38:19 +11:00
Hugo
e83479edf0 Merge pull request #2263 from wiredfool/tiff_bytesio
Fix for writing Tiff to BytesIO using libtiff
2016-12-09 11:04:41 +02:00
wiredfool
aa247dbb60 Moving tests requiring libtiff to test_file_libtiff 2016-12-05 08:25:10 -08:00
wiredfool
86606022c5 Merge pull request #2193 from SemanticsOS/lambdafu/libtiff-icc
Update info.icc_profile when using libtiff reader.
2016-12-03 13:44:26 +00:00
wiredfool
ce3432f5f4 Test for issue #2206 2016-11-23 06:24:40 -08:00
Jon Dufresne
dbe9f85c7d Drop support for Python 2.6
* Drop unittest2 requirement
* Use set literals
* Use dict/set comprehension
* Use str.format() automatic numbering
2016-11-22 04:23:55 -08:00
Marcus Brinkmann
66de02685f Update info.icc_profile when using libtiff reader. 2016-11-04 16:37:49 +01:00
wiredfool
b81da5a322 Tests for issue #1651 2016-09-29 22:29:19 +01:00
hugovk
2c4a1209f4 flake8 2016-08-04 09:40:12 +03:00
homm
1ba4e9e5ba remove end of file banner from all files 2016-07-10 14:11:28 +03:00
wiredfool
be2100be7b Skip tests that require libtiff if it is not installed, fixes #1866 2016-05-06 09:07:00 -07:00
wiredfool
14f3b45f46 Merge pull request #1789 from zwhfly/tiff
Add Support for 2/4 bpp Tiff Grayscale Images
2016-04-03 12:07:48 -07:00
Andrew Murray
677b958a7f Health fixes 2016-04-01 21:49:30 +11:00
zwhfly
124bee0485 Add Tests for 2/4 bpp Tiff Grayscale Images
Including inverted and/or bit-order-reversed formats.
2016-03-29 20:19:22 +08:00
wiredfool
e5076a3278 Merge pull request #1620 from wiredfool/issue_1597
Partial fix for #1597
2016-01-01 07:47:58 -08:00
wiredfool
36d4f5a9b4 Tests for permitted libtiff metadata 2016-01-01 05:30:40 -08:00
Andrew Murray
a83bcec169 Flake8 fixes 2015-12-31 07:27:27 +11:00
wiredfool
9fa6634f4d Partial fix for #1597
Haven't excercized all of the metadata that we're allowing yet,
and there's clearly still something up with Arrays, as one
of them is still crashing and making it impossible to save a
palette with a libtiff image.
2015-12-30 07:54:14 -08:00
wiredfool
b68bb56b64 test for issue #1561 2015-12-14 20:24:01 +00:00
wiredfool
05348d4f8f Reenabling failing/crashing tests, with fixes 2015-09-14 03:03:24 -07:00
wiredfool
c2818ee09e Add versioned api to tests 2015-09-13 16:19:40 +01:00
wiredfool
f3ab9b9f81 temp removing segfaulting test on travis 2015-09-13 14:38:51 +01:00
wiredfool
2636679868 updating tests for legacy_api api change 2015-09-13 14:08:49 +01:00
wiredfool
0c942911d9 fixed the rebase 2015-09-11 22:39:37 +01:00
Antony Lee
c113e8f7cd libtiff's rational precision is limited to C floats. 2015-09-11 22:39:37 +01:00
Antony Lee
93abbd0caa Restore legacy TIFF API.
To have the old API that always returns tuples, and fractions as pairs,
set the `legacy_api` attribute of the IFD to True.

This should alleviate concerns about backwards compatibility.
2015-09-11 22:39:37 +01:00
Antony Lee
974bcc074b Major rewrite of TIFF ImageFileDirectory.
Do not represent scalar tags as 1-element tuples.  Keep tag
type and count information in TiffTags.TAGS.  Normalize data in
ImageFileDirectory.__setitem__: wrap and unwrap tuples as needed,
convert rationals to floats.  (To ensure consistency, make the "tags"
attribute private.)  Interpret byte data as a series of integers rather
than a bytearray (which should only map to the "undefined" type).  On
Python3, if a str is assigned to an "undefined" tag, encode it as ASCII.

Note that a large number of tags have been removed from TiffTags.TAGS
because I do not have time to figure out the type and count of each of
them.  They should be restored before this gets merged in.

This obviously breaks backwards compatibility in a lot of ways...
2015-09-11 22:34:50 +01:00
Antony Lee
4e754e9c55 Use logging instead of print.
cf. #1191.

Only TiffImagePlugin and OLEFileIO still rely on (their own) DEBUG flag.
I left TiffImagePlugin as it is because I hope #1059 gets merged in
first, and OLEFileIO because it uses its own logic.

Untested, as usual.
2015-06-29 12:39:50 -07:00
Andrew Murray
4e2de9d9ed Added missing future print imports and removed unnecessary imports 2015-05-23 20:28:41 +10:00
Andrew Murray
ee34d6843b Further health fixes 2015-04-24 18:24:52 +10:00
Andrew Murray
7f414057c9 Fixed redefinition of built-in 2015-04-24 16:02:39 +10:00
Andrew Murray
d1c182cadc Various Flake8 fixes 2015-04-24 09:26:52 +10:00
Hugo
02476b7689 Remove unused variable, and other minor flake8 warnings 2014-11-17 10:33:31 +02:00
wiredfool
9a2cc7df83 hoist import, move test to libtiff 2014-11-15 20:38:52 -08:00
wiredfool
2d2474685a Added 4bit test to libtiff as well 2014-10-29 11:07:20 -07:00
Hugo
91aa29ca2b Replace lena with hopper 2014-09-23 16:16:04 +03:00
Hugo
925cea3780 Replace lena_g4.tif with hopper_g4.tif 2014-09-23 10:57:55 +03:00
hugovk
eb458c7c8f Replace lena.tif with hopper.tif (created with ImageMagick) 2014-09-05 12:14:45 +03:00
wiredfool
d8b2829f4b Partial fix for test failures, works on py2.x 2014-09-02 15:20:25 -07:00
wiredfool
b8bdd13aac Tests for multipage tiffs 2014-09-02 15:20:24 -07:00
wiredfool
3e361d800d Refactor inheritance tree of test_file_libtiff_small 2014-08-26 09:58:23 -07:00
hugovk
cf04a9a0d2 Remove unused tearDownModule 2014-07-07 20:03:50 +03:00
hugovk
3ec505958e Convert old tests to use unittest 2014-06-10 12:10:47 +03:00
hugovk
c9a4272af6 Replace python-imaging with python-pillow (but yet not Coveralls) 2014-06-03 13:02:44 +03:00
wiredfool
413a086c09 Remove READ|WRITE_LIBTIFF guards for LZW/packbits compression tests 2014-05-20 10:13:58 -07:00
wiredfool
65c17d4176 Removed warning import, stray im=None, and moved os import to top 2014-03-28 08:35:18 -07:00
wiredfool
b73b4a7b63 Tests for #526 2014-03-27 22:17:27 -07:00
cgohlke
55d4160bcc TST: fix comparison of X/Y Resolution rational numbers 2013-12-29 20:14:51 -08:00
wiredfool
aa1c0fdfb6 merge from master 2013-12-19 20:48:49 -08:00
wiredfool
543f96de61 Merge from master 2013-11-30 09:57:00 -08:00
wiredfool
c82bfd30cf cleanup temp file 2013-11-21 22:15:34 -08:00
wiredfool
6bd51e053b disabling bw compression test due to stderr pollution from libtiff 2013-11-21 22:14:29 -08:00
wiredfool
60c93ce1b1 Testing default pil implemented compressions with libtiff 2013-11-21 22:13:57 -08:00
wiredfool
94e3c75179 Merge from 12-bit-tiff 2013-11-21 21:41:54 -08:00
wiredfool
3d31bf394b removing libtiff compression based decoder names 2013-11-21 21:10:17 -08:00
wiredfool
019074670b Test for 12bit image using libtiff 2013-11-21 20:37:52 -08:00
wiredfool
0ffc1a848a Renamed test tiff files to 16bit*. They are 12bit data in a 16bit format 2013-11-19 14:48:01 -08:00
wiredfool
1d6f6ffa10 error test for bw compression on RGB file 2013-11-05 20:59:57 -08:00
wiredfool
a4a9b36ed0 packbits isn't working correctly 2013-11-05 20:53:18 -08:00
wiredfool
d2f1fa0e5f two additional tags for saving color images with libtiff 2013-11-05 20:49:09 -08:00
wiredfool
388c25b781 PhotometricInterpretation is set from SAVE_INFO, not the original image, so spurious test failure. 2013-10-23 20:50:01 -07:00
wiredfool
63995459bc merge from master 2013-10-22 16:18:06 -07:00
wiredfool
f8abb98ffd Merge from master 2013-10-22 16:05:18 -07:00
wiredfool
6357b4707c String attr test case 2013-10-22 10:09:25 -07:00
wiredfool
758da6c581 whitespace error 2013-10-22 10:06:33 -07:00
Eric Soroos
8d21ce1df7 py3k 2013-10-21 22:53:35 +00:00