summaryrefslogtreecommitdiff
path: root/tests/conftest.py
blob: 374483096d0006f6fd32b1ed08f5e479de75f814 (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 importlib.util
import json
import os
import sys

import pytest

_ROOT = os.path.dirname(os.path.dirname(__file__))
_SCRIPT = os.path.join(_ROOT, ".github", "scripts", "build-announcements.py")


@pytest.fixture(scope="session")
def mod():
    spec = importlib.util.spec_from_file_location("build_announcements", _SCRIPT)
    module = importlib.util.module_from_spec(spec)
    sys.modules["build_announcements"] = module
    spec.loader.exec_module(module)
    return module


@pytest.fixture(scope="session")
def releases():
    path = os.path.join(os.path.dirname(__file__), "fixtures", "bazzite-releases.json")
    with open(path, encoding="utf-8") as f:
        return json.load(f)


@pytest.fixture
def stable_release(releases):
    return next(r for r in releases if not r["prerelease"])