Pillow/Tests
Yay295 3af0e2d9cf add "new" rawmodes for 16-bit RGB data
The existing 16-bit RGB rawmodes do not follow the naming convention given in Unpack.c. These new modes do follow that convention, except since these modes do not all use the same number of bits for each band, the sizes of each band are listed.

Old → New
RGB;15 → XBGR;1555
RGB;16 → BGR;565
BGR;5 → XRGB;1555
BGR;15 → XRGB;1555
BGR;16 → RGB;565
RGB;4B → XBGR;4
RGBA;4B → ABGR;4
RGBA;15 → ABGR;1555
BGRA;15 → ARGB;1555
BGRA;15Z → ARGB;1555Z

These new rawmodes also use a slightly different conversion method. The most accurate conversion from 5 to 8 bits is "round(x * 255 / 31.0)". However, that involves floating point numbers and rounding, so it's not as fast. The current method doesn't include the rounding, allowing us to also use integer instead of floating point division. This is faster, but unfortunately not roundtrippable - when converting from 5 to 8 to 5 bits not every value stays the same. The new method is roundtrippable, even faster than the current method since it uses basic bitwise operations instead of multiplication and division, and if you compare the result to what you get with rounding and floating point numbers, it is actually more accurate.
2024-10-12 18:33:57 -05:00
..
fonts add test for glyph alpha blending 2023-11-27 16:25:04 +01:00
icc Use strncpy to avoid buffer overflow 2024-04-01 09:24:43 +03:00
images Test ignoring second ImageData 2024-10-05 16:28:03 -05:00
oss-fuzz Merge pull request #8339 from radarhere/type_hint 2024-09-04 14:57:01 +03: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 Add 'from __future__ import annotations' using Ruff/isort 2023-12-21 13:13:31 +02:00
check_fli_oob.py Remove shebangs 2024-01-29 18:43:03 +02:00
check_fli_overflow.py Merge branch 'main' into type_hints_check 2024-01-21 14:38:17 +11:00
check_icns_dos.py Add 'from __future__ import annotations' using Ruff/isort 2023-12-21 13:13:31 +02:00
check_imaging_leaks.py Added type hints 2024-03-02 13:12:17 +11:00
check_j2k_dos.py Add 'from __future__ import annotations' using Ruff/isort 2023-12-21 13:13:31 +02:00
check_j2k_leaks.py Merge branch 'main' into type_hints_check 2024-01-21 14:38:17 +11:00
check_j2k_overflow.py Use Path instead of PosixPath 2024-01-23 21:42:36 +11:00
check_jp2_overflow.py Remove shebang and execute bit 2024-01-29 18:43:51 +02:00
check_jpeg_leaks.py Merge branch 'main' into type_hints_check 2024-01-21 14:38:17 +11:00
check_large_memory_numpy.py Use Path instead of PosixPath 2024-01-23 21:42:36 +11:00
check_large_memory.py Use Path instead of PosixPath 2024-01-23 21:42:36 +11:00
check_libtiff_segfault.py Merge branch 'main' into type_hints_check 2024-01-21 14:38:17 +11:00
check_png_dos.py Added type hints 2024-03-02 13:12:17 +11:00
check_release_notes.py isort Tests 2024-01-20 13:23:03 +02:00
check_wheel.py Bring back removed features, add deprecations and Release notes 2024-08-13 09:34:49 +04:00
conftest.py Added type hints 2024-01-21 19:18:51 +11:00
createfontdatachunk.py isort Tests 2024-01-20 13:23:03 +02:00
helper.py Added type hints to tests (#8203) 2024-07-05 11:56:24 -06:00
README.rst Added pytest-timeout to test dependencies 2022-05-16 08:56:45 +10:00
test_000_sanity.py Added type hints 2024-01-27 15:19:43 +11:00
test_binary.py Added type hints 2024-01-27 15:19:43 +11:00
test_bmp_reference.py Added image to supported list 2024-04-10 20:37:44 +10:00
test_box_blur.py Return early if either width or height is zero 2024-09-05 15:46:54 +10:00
test_color_lut.py Use im property 2024-08-10 10:20:08 +10:00
test_core_resources.py Added type hints 2024-02-12 23:01:44 +11:00
test_decompression_bomb.py Added type hints 2024-06-09 15:16:17 +10:00
test_deprecate.py Bump deprecation tests to Pillow 12 2024-07-01 13:25:43 +03:00
test_features.py Always raise warnings for deprecated feature checks 2024-10-11 20:59:15 +11:00
test_file_apng.py Use transparency when combining P frames 2024-10-06 11:30:27 +11:00
test_file_blp.py Added type hints 2024-02-17 15:00:38 +11:00
test_file_bmp.py Added type hints 2024-06-05 22:27:23 +10:00
test_file_bufrstub.py Added type hints 2024-06-24 06:59:00 +10:00
test_file_container.py Changed ContainerIO to subclass IO 2024-07-17 16:23:29 +10:00
test_file_cur.py Added type hints 2024-01-27 15:19:43 +11:00
test_file_dcx.py Autotype tests (#7756) 2024-01-31 20:12:58 +11:00
test_file_dds.py Enforce CSV parametrize names style 2024-08-07 12:27:20 +03:00
test_file_eps.py Test ignoring second ImageData 2024-10-05 16:28:03 -05:00
test_file_fits.py Support GZIP_1 compression 2024-03-26 21:29:28 +11:00
test_file_fli.py fix FLI/FLC decoder for files with a prefix chunk 2024-02-22 09:13:48 +01:00
test_file_fpx.py Autotype tests (#7756) 2024-01-31 20:12:58 +11:00
test_file_ftex.py Added type hints 2024-01-27 15:19:43 +11:00
test_file_gbr.py Added type hints 2024-01-27 15:19:43 +11:00
test_file_gd.py Added type hints 2024-01-27 15:19:43 +11:00
test_file_gif.py Improved handling of RGBA palettes when saving GIF images 2024-09-10 18:50:06 +10:00
test_file_gimpgradient.py Autotype tests (#7756) 2024-01-31 20:12:58 +11:00
test_file_gimppalette.py Added type hints 2024-01-27 15:19:43 +11:00
test_file_gribstub.py Added type hints 2024-06-24 06:59:00 +10:00
test_file_hdf5stub.py Added type hints 2024-06-24 06:59:00 +10:00
test_file_icns.py Deprecate setting size to (width, height, scale) 2024-09-06 11:42:56 +10:00
test_file_ico.py Skip truncated mask if LOAD_TRUNCATED_IMAGES is enabled 2024-07-01 23:04:47 +10:00
test_file_im.py Added type hints 2024-02-17 15:00:38 +11:00
test_file_imt.py Added type hints 2024-01-27 15:19:43 +11:00
test_file_iptc.py Get IPTC info from tag_v2 2024-08-19 06:56:31 +10:00
test_file_jpeg.py Added type hints to frombuffer 2024-09-06 15:16:59 +10:00
test_file_jpeg2k.py Merge pull request #8256 from radarhere/jpeg2000_rgba 2024-09-04 14:48:01 +03:00
test_file_libtiff_small.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2024-02-05 17:18:52 +00:00
test_file_libtiff.py Rearranged code 2024-07-21 05:22:13 +10:00
test_file_mcidas.py Open 16-bit grayscale PNGs as I;16 2024-03-02 15:39:43 +11:00
test_file_mic.py Autotype tests (#7756) 2024-01-31 20:12:58 +11:00
test_file_mpeg.py Added MPEG accept function 2024-04-22 13:39:35 +10:00
test_file_mpo.py Corrected type hints 2024-07-20 19:07:42 +10:00
test_file_msp.py Added type hints 2024-02-20 15:41:20 +11:00
test_file_palm.py Added type hints 2024-02-12 23:01:44 +11:00
test_file_pcd.py Added type hints 2024-01-27 15:19:43 +11:00
test_file_pcx.py Added type hints 2024-07-02 20:10:47 +10:00
test_file_pdf.py Added type hint 2024-07-06 22:06:47 +10:00
test_file_pixar.py Added type hints 2024-01-27 15:19:43 +11:00
test_file_png.py Added type hints 2024-07-28 12:53:02 +10:00
test_file_ppm.py Merge pull request #8231 from radarhere/ppm_i16 2024-09-04 14:46:31 +03:00
test_file_psd.py Merge pull request #8039 from radarhere/psd_layers 2024-06-25 06:07:09 -06:00
test_file_qoi.py Added type hints 2024-01-27 15:19:43 +11:00
test_file_sgi.py Added type hints 2024-01-31 21:55:32 +11:00
test_file_spider.py Added type hints 2024-06-24 21:04:33 +10:00
test_file_sun.py Autotype tests (#7756) 2024-01-31 20:12:58 +11:00
test_file_tar.py Added type hints 2024-02-12 23:01:44 +11:00
test_file_tga.py Added test for non-colormap 16-bit image 2024-06-26 08:32:57 -05:00
test_file_tiff_metadata.py rewrite some comments 2024-09-20 08:39:11 -05:00
test_file_tiff.py Added additional test 2024-09-25 20:37:41 +10:00
test_file_wal.py Added type hints 2024-01-27 15:19:43 +11:00
test_file_webp_alpha.py Removed unnecessary variable 2024-08-13 19:03:14 +10:00
test_file_webp_animated.py Remove webp animations flags and conditions 2024-08-13 09:33:20 +04:00
test_file_webp_lossless.py Removed unnecessary variable 2024-08-13 19:03:14 +10:00
test_file_webp_metadata.py Catch defusedxml warnings 2024-08-23 18:48:28 +10:00
test_file_webp.py Test unsupported image mode 2024-09-21 16:02:23 +10:00
test_file_wmf.py Added type hints 2024-06-05 22:27:23 +10:00
test_file_xbm.py Autotype tests (#7756) 2024-01-31 20:12:58 +11:00
test_file_xpm.py Added type hints 2024-01-27 15:19:43 +11:00
test_file_xvthumb.py Added type hints 2024-01-27 15:19:43 +11:00
test_font_bdf.py Added type hints 2024-01-22 18:42:43 +11:00
test_font_crash.py Added type hints 2024-01-22 18:42:43 +11:00
test_font_leaks.py Updated type hints 2024-06-22 10:09:11 +10:00
test_font_pcf_charsets.py Use Path instead of PosixPath 2024-01-23 21:42:36 +11:00
test_font_pcf.py Added type hints 2024-07-25 22:55:49 +10:00
test_fontfile.py Added type hints 2024-01-27 15:19:43 +11:00
test_format_hsv.py Merge branch 'main' into unused 2024-02-17 18:23:04 +11:00
test_format_lab.py Added type hints 2024-01-27 15:19:43 +11:00
test_image_access.py Enforce CSV parametrize names style 2024-08-07 12:27:20 +03:00
test_image_array.py Merge branch 'python-pillow:main' into type_comparison 2024-09-05 13:31:36 +02:00
test_image_convert.py Added type hints to Image.__init__() 2024-08-02 23:30:27 +10:00
test_image_copy.py Use transposed size after opening for TIFF images 2024-09-18 20:26:06 +10:00
test_image_crop.py Added type hints 2024-06-01 21:31:53 +10:00
test_image_draft.py Updated type hints 2024-06-22 10:09:11 +10:00
test_image_entropy.py Added type hints 2024-02-12 09:28:53 +11:00
test_image_filter.py Support BuiltinFilter for I;16* images 2024-10-05 01:12:51 +10:00
test_image_frombytes.py Added type hints 2024-01-31 21:55:32 +11:00
test_image_fromqimage.py add typing to "ims" in test_image_fromqimage.py 2024-03-27 14:02:02 -05:00
test_image_getbands.py Added type hints 2024-01-25 22:18:46 +11:00
test_image_getbbox.py Added type hints 2024-01-25 22:18:46 +11:00
test_image_getcolors.py Added type hints to tests (#8203) 2024-07-05 11:56:24 -06:00
test_image_getdata.py Update Tests/test_image_getdata.py 2024-04-06 15:18:16 -05:00
test_image_getextrema.py Added type hints 2024-06-01 21:31:53 +10:00
test_image_getim.py Apply suggestions from code review 2024-10-07 13:05:13 +04:00
test_image_getpalette.py Added type hints 2024-02-12 09:28:53 +11:00
test_image_getprojection.py Added type hints 2024-01-25 22:18:46 +11:00
test_image_histogram.py Added type hints 2024-01-25 22:18:46 +11:00
test_image_load.py Added type hints 2024-07-02 20:10:47 +10:00
test_image_mode.py Added type hints 2024-06-09 15:16:17 +10:00
test_image_paste.py Added type hints 2024-07-02 20:10:47 +10:00
test_image_point.py Updated type hints 2024-06-22 10:09:11 +10:00
test_image_putalpha.py Added type hints 2024-01-25 22:18:46 +11:00
test_image_putdata.py Added type hints to tests (#8203) 2024-07-05 11:56:24 -06:00
test_image_putpalette.py Added type hints to Image.__init__() 2024-08-02 23:30:27 +10:00
test_image_quantize.py Added type hints to Image.__init__() 2024-08-02 23:30:27 +10:00
test_image_reduce.py Added type hints 2024-06-09 15:16:17 +10:00
test_image_resample.py Use im property 2024-08-10 10:20:08 +10:00
test_image_resize.py Set default resize sampling for I;16* images to BICUBIC 2024-09-28 15:35:42 +10:00
test_image_rotate.py Added type hints 2024-06-05 22:27:23 +10:00
test_image_split.py Added type hints 2024-01-25 22:18:46 +11:00
test_image_thumbnail.py Use transposed size after opening for TIFF images 2024-09-18 20:26:06 +10:00
test_image_tobitmap.py Added type hints 2024-01-25 22:18:46 +11:00
test_image_tobytes.py Added type hints 2024-01-25 22:18:46 +11:00
test_image_transform.py Added type hints to tests (#8203) 2024-07-05 11:56:24 -06:00
test_image_transpose.py Added type hints 2024-01-25 22:18:46 +11:00
test_image.py Lint: Run PT016 2024-09-14 20:59:02 +10:00
test_imagechops.py Fix PT018: Assert only one thing 2024-08-17 11:46:15 +03:00
test_imagecms.py Support converting more modes to LAB by converting to RGBA first 2024-09-07 12:14:30 +10:00
test_imagecolor.py Autotype tests (#7756) 2024-01-31 20:12:58 +11:00
test_imagedraw.py Accept float stroke widths 2024-09-11 19:53:52 +10:00
test_imagedraw2.py Pass start and end to arc, chord and pieslice 2024-07-30 09:10:11 +10:00
test_imageenhance.py Added type hints 2024-02-17 15:00:38 +11:00
test_imagefile.py Added type hints to frombuffer 2024-09-06 15:16:59 +10:00
test_imagefont.py Merge branch 'main' into improve-error-messages 2024-09-11 17:11:52 +02:00
test_imagefontctl.py Added type hints 2024-02-12 23:01:44 +11:00
test_imagefontpil.py Merge branch 'main' into load_default_imagefont 2024-06-24 08:04:53 +10:00
test_imagegrab.py Added type hints 2024-07-06 19:17:23 +10:00
test_imagemath_lambda_eval.py Deprecate lambda_eval and unsafe_eval options argument 2024-07-17 22:08:53 +10:00
test_imagemath_unsafe_eval.py Deprecate lambda_eval and unsafe_eval options argument 2024-07-17 22:08:53 +10:00
test_imagemorph.py Load before trying to catch exceptions 2024-09-21 16:22:50 +10:00
test_imageops_usm.py Use im property 2024-08-10 10:20:08 +10:00
test_imageops.py Remove webp animations flags and conditions 2024-08-13 09:33:20 +04:00
test_imagepalette.py Added type hints 2024-06-24 21:04:33 +10:00
test_imagepath.py Raise an error if path is compacted during mapping 2024-09-30 19:50:08 +10:00
test_imageqt.py Removed support for Qt 5 2024-06-22 00:39:37 +10:00
test_imagesequence.py Combine tests through parametrization 2024-04-19 17:15:10 +10:00
test_imageshow.py Fixed unclosed file warning 2024-10-07 16:50:05 +11:00
test_imagestat.py Added type hints 2024-05-30 17:17:22 +10:00
test_imagetk.py Added type hints 2024-07-08 20:09:45 +10:00
test_imagewin_pointers.py Added type hints 2024-06-24 06:59:00 +10:00
test_imagewin.py Cast handle to int 2024-09-16 08:23:26 +10:00
test_lib_image.py Use im property 2024-08-10 10:20:08 +10:00
test_lib_pack.py add "new" rawmodes for 16-bit RGB data 2024-10-12 18:33:57 -05:00
test_locale.py Fix typos 2024-03-31 15:57:20 +03:00
test_main.py Added type hints 2024-06-09 15:16:17 +10:00
test_map.py Autotype tests (#7756) 2024-01-31 20:12:58 +11:00
test_mode_i16.py Added type hints 2024-07-02 20:10:47 +10:00
test_numpy.py Use transposed size after opening for TIFF images 2024-09-18 20:26:06 +10:00
test_pdfparser.py Autotype tests (#7756) 2024-01-31 20:12:58 +11:00
test_pickle.py move eps test images to their own folder 2024-09-30 08:23:26 -05:00
test_psdraw.py Do not use sys.stdout in PSDraw 2024-08-20 22:13:52 +10:00
test_pyroma.py Added type hints 2024-01-27 15:19:43 +11:00
test_qt_image_qapplication.py Added type hints 2024-08-26 23:49:03 +10:00
test_qt_image_toqimage.py Added type hints 2024-08-26 23:49:03 +10:00
test_sgi_crash.py Added type hints 2024-02-12 23:01:44 +11:00
test_shell_injection.py Added type hints 2024-06-18 23:03:03 +10:00
test_tiff_crashes.py Added type hints 2024-03-02 13:12:17 +11:00
test_tiff_ifdrational.py Fix PT018: Assert only one thing 2024-08-17 11:46:15 +03:00
test_uploader.py Added type hints 2024-01-27 15:19:43 +11:00
test_util.py Remove unused _util.is_directory 2024-07-24 20:32:20 +03:00
test_webp_leaks.py Added type hints 2024-01-27 15:19:43 +11:00

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

Test scripts are named ``test_xxx.py``. Helper classes and functions can be found in ``helper.py``.

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

Install::

    python3 -m pip install pytest pytest-cov pytest-timeout

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