mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-10 08:30:49 +03:00
add tests for version numbers
This commit is contained in:
parent
6c1ff252d6
commit
d5a6b2584e
|
@ -1,4 +1,5 @@
|
||||||
import io
|
import io
|
||||||
|
import re
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from PIL import features
|
from PIL import features
|
||||||
|
@ -21,6 +22,27 @@ def test_check():
|
||||||
assert features.check_feature(feature) == features.check(feature)
|
assert features.check_feature(feature) == features.check(feature)
|
||||||
|
|
||||||
|
|
||||||
|
def test_version():
|
||||||
|
# Check the correctness of the convenience function
|
||||||
|
# and the format of version numbers
|
||||||
|
|
||||||
|
def test(name, function):
|
||||||
|
version = features.version(name)
|
||||||
|
if not features.check(name):
|
||||||
|
assert version is None
|
||||||
|
else:
|
||||||
|
assert function(name) == version
|
||||||
|
if name != "PIL":
|
||||||
|
assert version is None or re.search(r"\d+(\.\d+)*$", version)
|
||||||
|
|
||||||
|
for module in features.modules:
|
||||||
|
test(module, features.version_module)
|
||||||
|
for codec in features.codecs:
|
||||||
|
test(codec, features.version_codec)
|
||||||
|
for feature in features.features:
|
||||||
|
test(feature, features.version_feature)
|
||||||
|
|
||||||
|
|
||||||
@skip_unless_feature("webp")
|
@skip_unless_feature("webp")
|
||||||
def test_webp_transparency():
|
def test_webp_transparency():
|
||||||
assert features.check("transp_webp") != _webp.WebPDecoderBuggyAlpha()
|
assert features.check("transp_webp") != _webp.WebPDecoderBuggyAlpha()
|
||||||
|
@ -37,9 +59,22 @@ def test_webp_anim():
|
||||||
assert features.check("webp_anim") == _webp.HAVE_WEBPANIM
|
assert features.check("webp_anim") == _webp.HAVE_WEBPANIM
|
||||||
|
|
||||||
|
|
||||||
|
@skip_unless_feature("libjpeg_turbo")
|
||||||
|
def test_libjpeg_turbo_version():
|
||||||
|
assert re.search(r"\d+\.\d+\.\d+$", features.version("libjpeg_turbo"))
|
||||||
|
|
||||||
|
|
||||||
|
@skip_unless_feature("libimagequant")
|
||||||
|
def test_libimagequant_version():
|
||||||
|
assert re.search(r"\d+\.\d+\.\d+$", features.version("libimagequant"))
|
||||||
|
|
||||||
|
|
||||||
def test_check_modules():
|
def test_check_modules():
|
||||||
for feature in features.modules:
|
for feature in features.modules:
|
||||||
assert features.check_module(feature) in [True, False]
|
assert features.check_module(feature) in [True, False]
|
||||||
|
|
||||||
|
|
||||||
|
def test_check_codecs():
|
||||||
for feature in features.codecs:
|
for feature in features.codecs:
|
||||||
assert features.check_codec(feature) in [True, False]
|
assert features.check_codec(feature) in [True, False]
|
||||||
|
|
||||||
|
@ -64,6 +99,8 @@ def test_unsupported_codec():
|
||||||
# Act / Assert
|
# Act / Assert
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
features.check_codec(codec)
|
features.check_codec(codec)
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
features.version_codec(codec)
|
||||||
|
|
||||||
|
|
||||||
def test_unsupported_module():
|
def test_unsupported_module():
|
||||||
|
@ -72,6 +109,8 @@ def test_unsupported_module():
|
||||||
# Act / Assert
|
# Act / Assert
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
features.check_module(module)
|
features.check_module(module)
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
features.version_module(module)
|
||||||
|
|
||||||
|
|
||||||
def test_pilinfo():
|
def test_pilinfo():
|
||||||
|
|
|
@ -3,11 +3,12 @@ import io
|
||||||
import itertools
|
import itertools
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from ctypes import c_float
|
from ctypes import c_float
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from PIL import Image, ImageFilter, TiffImagePlugin, TiffTags
|
from PIL import Image, ImageFilter, TiffImagePlugin, TiffTags, features
|
||||||
|
|
||||||
from .helper import (
|
from .helper import (
|
||||||
assert_image_equal,
|
assert_image_equal,
|
||||||
|
@ -47,6 +48,9 @@ class LibTiffTestCase:
|
||||||
|
|
||||||
|
|
||||||
class TestFileLibTiff(LibTiffTestCase):
|
class TestFileLibTiff(LibTiffTestCase):
|
||||||
|
def test_version(self):
|
||||||
|
assert re.search(r"\d+\.\d+\.\d+$", features.version_codec("libtiff"))
|
||||||
|
|
||||||
def test_g4_tiff(self, tmp_path):
|
def test_g4_tiff(self, tmp_path):
|
||||||
"""Test the ordinary file path load path"""
|
"""Test the ordinary file path load path"""
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import io
|
import io
|
||||||
|
import re
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from PIL import Image, WebPImagePlugin
|
from PIL import Image, WebPImagePlugin, features
|
||||||
|
|
||||||
from .helper import (
|
from .helper import (
|
||||||
assert_image_similar,
|
assert_image_similar,
|
||||||
|
@ -38,6 +39,7 @@ class TestFileWebp:
|
||||||
def test_version(self):
|
def test_version(self):
|
||||||
_webp.WebPDecoderVersion()
|
_webp.WebPDecoderVersion()
|
||||||
_webp.WebPDecoderBuggyAlpha()
|
_webp.WebPDecoderBuggyAlpha()
|
||||||
|
assert re.search(r"\d+\.\d+\.\d+$", features.version_module("webp"))
|
||||||
|
|
||||||
def test_read_rgb(self):
|
def test_read_rgb(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user