summaryrefslogtreecommitdiff
path: root/tests/test_private_pdfs.py
blob: 410f698295272cfd8242deabb59f25af34650bfe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import gzip
import os
import platform
import shutil
from contextlib import suppress
from pathlib import Path
from shutil import copy

import pytest

from pikepdf import Pdf, PdfError

# Files with unknown copyright status can't be shared publicly
PRIVATE_RESOURCES = Path(__file__).parent / 'resources' / 'private'


@pytest.fixture
def private():
    return Path(PRIVATE_RESOURCES)


pytestmark = pytest.mark.skipif(
    not PRIVATE_RESOURCES.is_dir(), reason='private resources not available'
)


def test_pypdf2_issue_361(private):
    with gzip.open(str(private / 'pypdf2_issue_361.pdf.gz'), 'rb') as gz:
        with pytest.raises(PdfError, match=r'trailer'):
            Pdf.open(gz)