Pillow/Tests
Jon Dufresne 2c50723f14 Convert some tests to pytest style
To better follow conventional pytest style, this removes the outer
wrapper class in favor of a function for some tests. These tests were
picked as they are relatively simple and presented no barriers to a
quick port. The assert* methods are replaced with assert statements.
When necessary, a fixture is used to create a temporary directory.

This commit does not convert the entire test suite to this style as some
test classes use methods or other advanced features that are difficult
to automatically convert. The goal is to address these issues in
followup commits.

Refs #4193
2020-01-18 12:12:10 -08:00
..
fonts add test for #3777 2019-06-25 22:16:00 +10:00
icc Corrected filename [ci skip] 2016-05-03 19:23:51 +10:00
images Overflow checks for realloc for tiff decoding 2020-01-02 15:24:46 +11:00
__init__.py Improve pytest configuration to allow specific tests as CLI args 2019-01-13 09:00:12 -08:00
32bit_segfault_check.py Introduce isort to automate import ordering and formatting 2019-07-06 16:11:35 -07:00
bench_cffi_access.py Import unittest from stdlib rather than helper.py 2019-11-20 18:42:52 -08:00
check_fli_overflow.py Use context managers 2019-11-26 07:03:23 +11:00
check_icns_dos.py Use bytes literals instead of bytes(str) 2019-10-06 19:26:55 -07:00
check_imaging_leaks.py Import unittest from stdlib rather than helper.py 2019-11-20 18:42:52 -08:00
check_j2k_dos.py Use bytes literals instead of bytes(str) 2019-10-06 19:26:55 -07:00
check_j2k_leaks.py Import unittest from stdlib rather than helper.py 2019-11-20 18:42:52 -08:00
check_j2k_overflow.py Import unittest from stdlib rather than helper.py 2019-11-20 18:42:52 -08:00
check_jpeg_leaks.py Import unittest from stdlib rather than helper.py 2019-11-20 18:42:52 -08:00
check_large_memory_numpy.py Import unittest from stdlib rather than helper.py 2019-11-20 18:42:52 -08:00
check_large_memory.py Import unittest from stdlib rather than helper.py 2019-11-20 18:42:52 -08:00
check_libtiff_segfault.py Use context managers 2019-11-26 07:03:23 +11:00
check_png_dos.py Import unittest from stdlib rather than helper.py 2019-11-20 18:42:52 -08:00
conftest.py Use features.pilinfo to report details about Pillow 2019-11-02 15:12:52 -07:00
createfontdatachunk.py Upgrade Python syntax with pyupgrade --py3-plus 2019-10-07 14:30:59 +03:00
helper.py Removed print 2020-01-14 19:44:10 +11:00
README.rst Cover tests https://nedbatchelder.com/blog/201908/dont_omit_tests_from_coverage.html 2019-11-20 17:28:12 +02:00
test_000_sanity.py Convert some tests to pytest style 2020-01-18 12:12:10 -08:00
test_binary.py Convert some tests to pytest style 2020-01-18 12:12:10 -08:00
test_bmp_reference.py Merge remote-tracking branch 'upstream/master' into rm-2.7 2019-11-01 13:22:56 +02:00
test_box_blur.py Convert some tests to pytest style 2020-01-18 12:12:10 -08:00
test_color_lut.py Import unittest from stdlib rather than helper.py 2019-11-20 18:42:52 -08:00
test_core_resources.py Convert some tests to pytest style 2020-01-18 12:12:10 -08:00
test_decompression_bomb.py Improve handling of file resources 2019-10-12 08:27:17 -07:00
test_features.py Import unittest from stdlib rather than helper.py 2019-11-20 18:42:52 -08:00
test_file_blp.py Use context managers 2019-11-26 07:03:23 +11:00
test_file_bmp.py Raise an error if BMP file size is too large when saving 2019-12-21 08:37:40 +11:00
test_file_bufrstub.py Convert some tests to pytest style 2020-01-18 12:12:10 -08:00
test_file_container.py Convert some tests to pytest style 2020-01-18 12:12:10 -08:00
test_file_cur.py Use context managers 2019-11-26 07:03:23 +11:00
test_file_dcx.py Improve handling of file resources 2019-10-12 08:27:17 -07:00
test_file_dds.py Use context managers 2019-11-26 07:03:23 +11:00
test_file_eps.py Use context managers 2019-11-26 07:03:23 +11:00
test_file_fitsstub.py Improve handling of file resources 2019-10-12 08:27:17 -07:00
test_file_fli.py Improve handling of file resources 2019-10-12 08:27:17 -07:00
test_file_fpx.py Raise an error for an invalid number of bands in FPX image 2020-01-02 15:20:24 +11:00
test_file_ftex.py Use context managers 2019-11-26 07:03:23 +11:00
test_file_gbr.py Improve handling of file resources 2019-10-12 08:27:17 -07:00
test_file_gd.py Convert some tests to pytest style 2020-01-18 12:12:10 -08:00
test_file_gif.py Allow string comment when saving GIF 2020-01-01 13:29:39 +11:00
test_file_gimpgradient.py Introduce isort to automate import ordering and formatting 2019-07-06 16:11:35 -07:00
test_file_gimppalette.py Convert some tests to pytest style 2020-01-18 12:12:10 -08:00
test_file_gribstub.py Improve handling of file resources 2019-10-12 08:27:17 -07:00
test_file_hdf5stub.py Improve handling of file resources 2019-10-12 08:27:17 -07:00
test_file_icns.py Use context managers 2019-11-26 07:03:23 +11:00
test_file_ico.py Use context managers 2019-11-26 07:03:23 +11:00
test_file_im.py Improve handling of file resources 2019-10-12 08:27:17 -07:00
test_file_iptc.py Merge remote-tracking branch 'upstream/master' into rm-2.7 2019-11-01 13:22:56 +02:00
test_file_jpeg.py Merge pull request #4147 from beipang2/issue_4146 2019-12-25 20:26:27 +11:00
test_file_jpeg2k.py Test on new Travis CPUs https://blog.travis-ci.com/2019-11-12-multi-cpu-architecture-ibm-power-ibm-z 2020-01-08 15:43:27 +02:00
test_file_libtiff_small.py Use context managers 2019-11-26 07:03:23 +11:00
test_file_libtiff.py Overflow checks for realloc for tiff decoding 2020-01-02 15:24:46 +11:00
test_file_mcidas.py Use context managers 2019-11-26 07:03:23 +11:00
test_file_mic.py Import unittest from stdlib rather than helper.py 2019-11-20 18:42:52 -08:00
test_file_mpo.py Raise a specific exception if no data is found for an MPO frame 2019-11-30 11:05:36 +11:00
test_file_msp.py Simplified conditions 2019-12-25 15:32:38 +11:00
test_file_palm.py Introduce isort to automate import ordering and formatting 2019-07-06 16:11:35 -07:00
test_file_pcd.py Use context managers 2019-11-26 07:03:23 +11:00
test_file_pcx.py Use context managers 2019-11-26 07:03:23 +11:00
test_file_pdf.py Use context managers 2019-11-26 07:03:23 +11:00
test_file_pixar.py Use context managers 2019-11-26 07:03:23 +11:00
test_file_png.py Test on new Travis CPUs https://blog.travis-ci.com/2019-11-12-multi-cpu-architecture-ibm-power-ibm-z 2020-01-08 15:43:27 +02:00
test_file_ppm.py Use context managers 2019-11-26 07:03:23 +11:00
test_file_psd.py Corrected context manager test 2019-11-06 20:12:19 +11:00
test_file_sgi.py Use context managers 2019-11-26 07:03:23 +11:00
test_file_spider.py Simplified code 2020-01-14 20:20:30 +11:00
test_file_sun.py Simplified conditions 2019-12-25 15:32:38 +11:00
test_file_tar.py Use context managers 2019-11-26 07:03:23 +11:00
test_file_tga.py Test saving with incorrect mode 2020-01-14 21:38:17 +11:00
test_file_tiff_metadata.py Changed _limit_signed_rational 2019-12-31 19:12:33 +11:00
test_file_tiff.py Use context managers 2019-11-26 07:03:23 +11:00
test_file_wal.py Convert some tests to pytest style 2020-01-18 12:12:10 -08:00
test_file_webp_alpha.py Use context managers 2019-11-26 07:03:23 +11:00
test_file_webp_animated.py Test seek errors 2020-01-14 21:38:17 +11:00
test_file_webp_lossless.py Use context managers 2019-11-26 07:03:23 +11:00
test_file_webp_metadata.py Use context managers 2019-11-26 07:03:23 +11:00
test_file_webp.py Simplified conditions 2019-12-25 15:32:38 +11:00
test_file_wmf.py fix deprecation warnings in test_file_wmf 2020-01-01 01:55:06 +01:00
test_file_xbm.py Roundtrip test hotspot 2020-01-14 21:38:17 +11:00
test_file_xpm.py Use context managers 2019-11-26 07:03:23 +11:00
test_file_xvthumb.py Use context managers 2019-11-26 07:03:23 +11:00
test_font_bdf.py Introduce isort to automate import ordering and formatting 2019-07-06 16:11:35 -07:00
test_font_leaks.py Simplified conditions 2019-12-25 15:32:38 +11:00
test_font_pcf.py Drop support for EOL Python 2.7 2019-10-07 14:30:59 +03:00
test_format_hsv.py Drop support for EOL Python 2.7 2019-10-07 14:30:59 +03:00
test_format_lab.py Convert some tests to pytest style 2020-01-18 12:12:10 -08:00
test_image_access.py Import unittest from stdlib rather than helper.py 2019-11-20 18:42:52 -08:00
test_image_array.py Merge pull request #4181 from pwohlhart/patch-1 2019-11-30 21:12:05 +11:00
test_image_convert.py Use context managers 2019-11-26 07:03:23 +11:00
test_image_copy.py Introduce isort to automate import ordering and formatting 2019-07-06 16:11:35 -07:00
test_image_crop.py Use context managers 2019-11-26 07:03:23 +11:00
test_image_draft.py linter fixes 2019-11-24 15:32:45 +03:00
test_image_entropy.py Fix wrong tests 2019-12-31 04:12:50 +03:00
test_image_filter.py Use context managers 2019-11-26 07:03:23 +11:00
test_image_frombytes.py Introduce isort to automate import ordering and formatting 2019-07-06 16:11:35 -07:00
test_image_fromqimage.py Upgrade Python syntax with pyupgrade --py3-plus 2019-11-01 13:54:19 +02:00
test_image_getbands.py Convert some tests to pytest style 2020-01-18 12:12:10 -08:00
test_image_getbbox.py Convert some tests to pytest style 2020-01-18 12:12:10 -08:00
test_image_getcolors.py Format with Black 2019-06-13 18:54:24 +03:00
test_image_getdata.py Fix wrong tests 2019-12-31 04:12:50 +03:00
test_image_getextrema.py Test on new Travis CPUs https://blog.travis-ci.com/2019-11-12-multi-cpu-architecture-ibm-power-ibm-z 2020-01-08 15:43:27 +02:00
test_image_getim.py Convert some tests to pytest style 2020-01-18 12:12:10 -08:00
test_image_getpalette.py Convert some tests to pytest style 2020-01-18 12:12:10 -08:00
test_image_getprojection.py Introduce isort to automate import ordering and formatting 2019-07-06 16:11:35 -07:00
test_image_histogram.py Fix wrong tests 2019-12-31 04:12:50 +03:00
test_image_load.py Introduce isort to automate import ordering and formatting 2019-07-06 16:11:35 -07:00
test_image_mode.py Improve handling of file resources 2019-10-12 08:27:17 -07:00
test_image_paste.py Introduce isort to automate import ordering and formatting 2019-07-06 16:11:35 -07:00
test_image_point.py Format with Black 2019-06-13 18:54:24 +03:00
test_image_putalpha.py Introduce isort to automate import ordering and formatting 2019-07-06 16:11:35 -07:00
test_image_putdata.py Introduce isort to automate import ordering and formatting 2019-07-06 16:11:35 -07:00
test_image_putpalette.py Convert some tests to pytest style 2020-01-18 12:12:10 -08:00
test_image_quantize.py Use context managers 2019-11-26 07:03:23 +11:00
test_image_reduce.py wording 2019-12-27 14:27:37 +03:00
test_image_resample.py Moved messages into assert method calls 2020-01-14 20:20:19 +11:00
test_image_resize.py fix formatting 2019-12-20 20:42:00 +03:00
test_image_rotate.py Use context managers 2019-11-26 07:03:23 +11:00
test_image_split.py Use context managers 2019-11-26 07:03:23 +11:00
test_image_thumbnail.py Merge branch 'reduce' into reduce-in-resize 2019-12-20 20:27:11 +03:00
test_image_tobitmap.py Introduce isort to automate import ordering and formatting 2019-07-06 16:11:35 -07:00
test_image_tobytes.py Convert some tests to pytest style 2020-01-18 12:12:10 -08:00
test_image_transform.py Use context managers 2019-11-26 07:03:23 +11:00
test_image_transpose.py Introduce isort to automate import ordering and formatting 2019-07-06 16:11:35 -07:00
test_image.py Catch SGI buffer overruns 2020-01-02 15:24:36 +11:00
test_imagechops.py Use context managers 2019-11-26 07:03:23 +11:00
test_imagecms.py Use context managers 2019-11-26 07:03:23 +11:00
test_imagecolor.py Fix wrong tests 2019-12-31 04:12:50 +03:00
test_imagedraw.py Change default resize resampling filter 2019-12-07 18:08:19 +03:00
test_imagedraw2.py Import unittest from stdlib rather than helper.py 2019-11-20 18:42:52 -08:00
test_imageenhance.py Upgrade Python syntax with pyupgrade --py3-plus 2019-10-07 14:30:59 +03:00
test_imagefile.py Change default resize resampling filter 2019-12-07 18:08:19 +03:00
test_imagefont_bitmap.py Simplified conditions 2019-12-25 15:32:38 +11:00
test_imagefont.py Use context managers 2019-11-26 07:03:23 +11:00
test_imagefontctl.py Use context managers 2019-11-26 07:03:23 +11:00
test_imagegrab.py Test grab bbox 2020-01-14 21:38:17 +11:00
test_imagemath.py Upgrade Python syntax with pyupgrade --py3-plus 2019-10-07 14:30:59 +03:00
test_imagemorph.py Use context managers 2019-11-26 07:03:23 +11:00
test_imageops_usm.py Upgrade Python syntax with pyupgrade --py3-plus 2019-11-01 13:54:19 +02:00
test_imageops.py Use context managers 2019-11-26 07:03:23 +11:00
test_imagepalette.py Use context managers 2019-11-26 07:03:23 +11:00
test_imagepath.py Drop support for EOL Python 2.7 2019-10-07 14:30:59 +03:00
test_imageqt.py Merge branch 'master' into rm-2.7 2019-10-26 09:07:44 +03:00
test_imagesequence.py Improve handling of file resources 2019-10-12 08:27:17 -07:00
test_imageshow.py Import unittest from stdlib rather than helper.py 2019-11-20 18:42:52 -08:00
test_imagestat.py Convert some tests to pytest style 2020-01-18 12:12:10 -08:00
test_imagetk.py Simplified conditions 2019-12-25 15:32:38 +11:00
test_imagewin_pointers.py Tests.helper cleanup 2019-09-25 11:58:02 +02:00
test_imagewin.py Import unittest from stdlib rather than helper.py 2019-11-20 18:42:52 -08:00
test_lib_image.py Import unittest from stdlib rather than helper.py 2019-11-20 18:42:52 -08:00
test_lib_pack.py Concatenate string literals on same line 2019-12-26 17:08:36 +02:00
test_locale.py Convert some tests to pytest style 2020-01-18 12:12:10 -08:00
test_main.py Convert some tests to pytest style 2020-01-18 12:12:10 -08:00
test_map.py Import unittest from stdlib rather than helper.py 2019-11-20 18:42:52 -08:00
test_mode_i16.py Merge remote-tracking branch 'upstream/master' into rm-2.7 2019-11-01 13:22:56 +02:00
test_numpy.py Use context managers 2019-11-26 07:03:23 +11:00
test_pdfparser.py Upgrade Python syntax with pyupgrade --py3-plus 2019-10-07 14:30:59 +03:00
test_pickle.py Use context managers 2019-11-26 07:03:23 +11:00
test_psdraw.py Use context managers 2019-11-26 07:03:23 +11:00
test_pyroma.py Import unittest from stdlib rather than helper.py 2019-11-20 18:42:52 -08:00
test_qt_image_fromqpixmap.py Introduce isort to automate import ordering and formatting 2019-07-06 16:11:35 -07:00
test_qt_image_toqimage.py Use context managers 2019-11-26 07:03:23 +11:00
test_qt_image_toqpixmap.py Introduce isort to automate import ordering and formatting 2019-07-06 16:11:35 -07:00
test_shell_injection.py Use context managers 2019-11-26 07:03:23 +11:00
test_tiff_ifdrational.py Improve handling of file resources 2019-10-12 08:27:17 -07:00
test_uploader.py Format with Black 2019-06-13 18:54:46 +03:00
test_util.py Convert some tests to pytest style 2020-01-18 12:12:10 -08:00
test_webp_leaks.py Import unittest from stdlib rather than helper.py 2019-11-20 18:42:52 -08:00

Pillow Tests
============

Test scripts are named ``test_xxx.py`` and use the ``unittest`` module. A base class and helper functions can be found in ``helper.py``.

Dependencies
------------

Install::

    pip install pytest pytest-cov

Execution
---------

To run an individual test::

    pytest Tests/test_image.py

Or::

    pytest -k test_image.py

Run all the tests from the root of the Pillow source distribution::

    pytest

Or with coverage::

    pytest --cov PIL --cov Tests --cov-report term
    coverage html
    open htmlcov/index.html