|
1 | 1 | import builtins |
2 | 2 | import os |
3 | | -import sys |
4 | 3 | from pathlib import Path |
5 | 4 |
|
6 | 5 | import dataset |
| 6 | +import helpers |
7 | 7 | import pytest |
8 | 8 |
|
9 | 9 | import pillow_heif |
|
13 | 13 |
|
14 | 14 | def test_libheif_info(): |
15 | 15 | info = pillow_heif.libheif_info() |
16 | | - assert info["version"]["libheif"] == "1.12.0" |
| 16 | + assert info["version"]["libheif"] in ("1.12.0", "1.13.0") |
17 | 17 | assert info["decoders"]["HEVC"] |
18 | | - if os.getenv("PH_LIGHT", "0") != "0" or sys.maxsize <= 2**32: |
19 | | - return |
20 | | - assert info["decoders"]["AV1"] |
21 | | - assert info["encoders"]["AV1"] |
22 | | - assert info["encoders"]["HEVC"] |
| 18 | + |
| 19 | + |
| 20 | +@pytest.mark.skipif(helpers.aom_enc() and helpers.aom_dec(), reason="Only when AOM missing.") |
| 21 | +@pytest.mark.skipif(pillow_heif.libheif_info()["version"]["aom"] == "Rav1e encoder", reason="Rav1e not supported") |
| 22 | +def test_pillow_register_avif_plugin(): |
| 23 | + with pytest.warns(UserWarning): |
| 24 | + pillow_heif.register_avif_opener() |
23 | 25 |
|
24 | 26 |
|
25 | 27 | @pytest.mark.parametrize("img_path", dataset.FULL_DATASET) |
@@ -63,3 +65,21 @@ def test_heif_str(): |
63 | 65 | assert str(heif_file.thumbnails[0]) == f"{str_thumb_nl} Original:{str_img_l_1}" |
64 | 66 | heif_file.thumbnails[0].load() # Should not change anything, thumbnails are cloned without data. |
65 | 67 | assert str(heif_file.thumbnails[0]) == f"{str_thumb_nl} Original:{str_img_l_1}" |
| 68 | + |
| 69 | + |
| 70 | +@pytest.mark.skipif(not helpers.RELEASE_FULL_FLAG, reason="Only when building full release") |
| 71 | +def test_full_build(): |
| 72 | + info = pillow_heif.libheif_info() |
| 73 | + assert info["decoders"]["AV1"] |
| 74 | + assert info["encoders"]["AV1"] |
| 75 | + assert info["encoders"]["HEVC"] |
| 76 | + assert info["version"]["libheif"] == os.getenv("EXP_PH_LIBHEIF_VERSION", "1.13.0") |
| 77 | + |
| 78 | + |
| 79 | +@pytest.mark.skipif(not helpers.RELEASE_LIGHT_FLAG, reason="Only when building light release") |
| 80 | +def test_light_build(): |
| 81 | + info = pillow_heif.libheif_info() |
| 82 | + assert not info["decoders"]["AV1"] |
| 83 | + assert not info["encoders"]["AV1"] |
| 84 | + assert not info["encoders"]["HEVC"] |
| 85 | + assert info["version"]["libheif"] == os.getenv("EXP_PH_LIBHEIF_VERSION", "1.13.0") |
0 commit comments