summaryrefslogtreecommitdiff
path: root/tests/conftest.py
blob: 398c7ecf2ebc2b6c83155b1ae7d2b9f767136da7 (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
31
32
33
34
35
36
37
38
39
import importlib.util
import os
import pytest


def _load_generate_sitemap():
    script_path = os.path.join(
        os.path.dirname(__file__), "..", "scripts", "generate-sitemap.py"
    )
    spec = importlib.util.spec_from_file_location("generate_sitemap", script_path)
    mod = importlib.util.module_from_spec(spec)
    # Load the module from its file path (required because filename contains a hyphen)
    spec.loader.exec_module(mod)
    return mod


@pytest.fixture(scope="session")
def sitemap_module():
    return _load_generate_sitemap()


@pytest.fixture(scope="session")
def find_pages(sitemap_module):
    return sitemap_module.find_pages


@pytest.fixture(scope="session")
def derive_url(sitemap_module):
    return sitemap_module.derive_url


@pytest.fixture(scope="session")
def get_heuristics(sitemap_module):
    return sitemap_module.get_heuristics


@pytest.fixture(scope="session")
def generate_sitemap(sitemap_module):
    return sitemap_module.generate_sitemap