Skip to content

Commit 4a706c7

Browse files
tests/: added test_4479().
1 parent 6d3d30d commit 4a706c7

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

tests/resources/test_4479.pdf

156 KB
Binary file not shown.

tests/test_general.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,3 +1834,43 @@ def test_4466():
18341834
pixmap = page.get_pixmap(clip=(0, 0, 10, 10))
18351835
print(f'{pixmap.n=} {pixmap.size=} {pixmap.stride=} {pixmap.width=} {pixmap.height=} {pixmap.x=} {pixmap.y=}', flush=1)
18361836
pixmap.is_unicolor # Used to crash.
1837+
1838+
1839+
def test_4479():
1840+
# This passes with pymupdf-1.24.14, fails with pymupdf==1.25.*, passes with
1841+
# pymupdf-1.26.0.
1842+
print()
1843+
path = os.path.normpath(f'{__file__}/../../tests/resources/test_4479.pdf')
1844+
with pymupdf.open(path) as document:
1845+
1846+
def show(items):
1847+
for item in items:
1848+
print(f' {repr(item)}')
1849+
1850+
items = document.layer_ui_configs()
1851+
show(items)
1852+
assert items == [
1853+
{'depth': 0, 'locked': 0, 'number': 0, 'on': 1, 'text': 'layer_0', 'type': 'checkbox'},
1854+
{'depth': 0, 'locked': 0, 'number': 1, 'on': 1, 'text': 'layer_1', 'type': 'checkbox'},
1855+
{'depth': 0, 'locked': 0, 'number': 2, 'on': 0, 'text': 'layer_2', 'type': 'checkbox'},
1856+
{'depth': 0, 'locked': 0, 'number': 3, 'on': 1, 'text': 'layer_3', 'type': 'checkbox'},
1857+
{'depth': 0, 'locked': 0, 'number': 4, 'on': 1, 'text': 'layer_4', 'type': 'checkbox'},
1858+
{'depth': 0, 'locked': 0, 'number': 5, 'on': 1, 'text': 'layer_5', 'type': 'checkbox'},
1859+
{'depth': 0, 'locked': 0, 'number': 6, 'on': 1, 'text': 'layer_6', 'type': 'checkbox'},
1860+
{'depth': 0, 'locked': 0, 'number': 7, 'on': 1, 'text': 'layer_7', 'type': 'checkbox'},
1861+
]
1862+
1863+
document.set_layer_ui_config(0, pymupdf.PDF_OC_OFF)
1864+
items = document.layer_ui_configs()
1865+
show(items)
1866+
assert items == [
1867+
{'depth': 0, 'locked': 0, 'number': 0, 'on': 0, 'text': 'layer_0', 'type': 'checkbox'},
1868+
{'depth': 0, 'locked': 0, 'number': 1, 'on': 1, 'text': 'layer_1', 'type': 'checkbox'},
1869+
{'depth': 0, 'locked': 0, 'number': 2, 'on': 0, 'text': 'layer_2', 'type': 'checkbox'},
1870+
{'depth': 0, 'locked': 0, 'number': 3, 'on': 1, 'text': 'layer_3', 'type': 'checkbox'},
1871+
{'depth': 0, 'locked': 0, 'number': 4, 'on': 1, 'text': 'layer_4', 'type': 'checkbox'},
1872+
{'depth': 0, 'locked': 0, 'number': 5, 'on': 1, 'text': 'layer_5', 'type': 'checkbox'},
1873+
{'depth': 0, 'locked': 0, 'number': 6, 'on': 1, 'text': 'layer_6', 'type': 'checkbox'},
1874+
{'depth': 0, 'locked': 0, 'number': 7, 'on': 1, 'text': 'layer_7', 'type': 'checkbox'},
1875+
]
1876+

0 commit comments

Comments
 (0)