diff options
author | James R. Barlow <jim@purplerock.ca> | 2019-02-21 11:57:00 -0800 |
---|---|---|
committer | James R. Barlow <jim@purplerock.ca> | 2019-02-21 11:57:00 -0800 |
commit | e0bca5478fc9b48cc3538a8e16ce2bd9b8c71075 (patch) | |
tree | 50d644a05e077cc4d14ca1c3684bca62bd6c4546 /tests | |
parent | 4d22fe47912c518e8b3348aedccdac3f11ed81d7 (diff) |
Add issue #27 to test suite
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_sanity.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/test_sanity.py b/tests/test_sanity.py index e63c99e..c80fb42 100644 --- a/tests/test_sanity.py +++ b/tests/test_sanity.py @@ -5,6 +5,8 @@ A bunch of quick tests that confirm nothing is horribly wrong import gc from contextlib import suppress from shutil import copy +from concurrent.futures import ThreadPoolExecutor, as_completed, TimeoutError +from io import BytesIO import pytest @@ -137,3 +139,17 @@ def test_readme_example(resources, outdir): del pdf.pages[-1] assert len(pdf.pages) == 3 pdf.save(outdir / 'output.pdf') + + +@pytest.mark.xfail(raises=TimeoutError, reason="pybind11 2.2.4 deadlock") +def test_threading(resources): + pdf_bytes = (resources / 'graph.pdf').read_bytes() + + def worker(): + pdf = pikepdf.open(BytesIO(pdf_bytes)) + return pdf.docinfo.Title + + with ThreadPoolExecutor(max_workers=1) as executor: + task = executor.submit(worker, pdf_bytes) + future = as_completed([task], timeout=1) + assert next(future) |