authentik.lib.tests.utils

Test utils

 1"""Test utils"""
 2
 3from inspect import currentframe
 4from pathlib import Path
 5
 6
 7def load_fixture(path: str, path_only=False, **kwargs) -> str:
 8    """Load fixture, optionally formatting it with kwargs"""
 9    current = currentframe()
10    parent = current.f_back
11    calling_file_path = parent.f_globals["__file__"]
12    fixture_path = Path(calling_file_path).resolve().parent / Path(path)
13    if path_only:
14        return fixture_path
15    with open(fixture_path, encoding="utf-8") as _fixture:
16        fixture = _fixture.read()
17        try:
18            return fixture % kwargs
19        except TypeError, ValueError:
20            return fixture
def load_fixture(path: str, path_only=False, **kwargs) -> str:
 8def load_fixture(path: str, path_only=False, **kwargs) -> str:
 9    """Load fixture, optionally formatting it with kwargs"""
10    current = currentframe()
11    parent = current.f_back
12    calling_file_path = parent.f_globals["__file__"]
13    fixture_path = Path(calling_file_path).resolve().parent / Path(path)
14    if path_only:
15        return fixture_path
16    with open(fixture_path, encoding="utf-8") as _fixture:
17        fixture = _fixture.read()
18        try:
19            return fixture % kwargs
20        except TypeError, ValueError:
21            return fixture

Load fixture, optionally formatting it with kwargs