File size: 617 Bytes
546c207
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""Shared fixtures. The tests run against the real `1.pdf` — it is fixed and
committed, so it is the fixture."""

import pytest

from spareparts import build_index, config, pdf_loader


@pytest.fixture(scope="session")
def doc():
    document = pdf_loader.open_document(config.PDF_PATH)
    yield document
    document.close()


@pytest.fixture(scope="session")
def built(tmp_path_factory):
    """Build the index once into a throwaway directory."""
    out = tmp_path_factory.mktemp("index")
    summary = build_index.build(
        config.PDF_PATH, out / "catalog.db", out / "pages"
    )
    return summary, out