inputs: add new "inputs_module" fixture
This commit is contained in:
parent
3824c9c868
commit
2d71935a91
2 changed files with 22 additions and 1 deletions
21
inputs/test/conftest.py
Normal file
21
inputs/test/conftest.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import os
|
||||
import pathlib
|
||||
from types import ModuleType
|
||||
|
||||
import pytest
|
||||
|
||||
from osbuild.testutil.imports import import_module_from_path
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def inputs_module(request: pytest.FixtureRequest) -> ModuleType:
|
||||
"""inputs_module is a fixture that imports a stage module by its name
|
||||
defined in INPUTS_NAME in the test module.
|
||||
"""
|
||||
if not hasattr(request.module, "INPUTS_NAME"):
|
||||
raise ValueError("inputs_module fixture must be used in a test module that defines INPUTS_NAME")
|
||||
|
||||
inputs_name = request.module.INPUTS_NAME
|
||||
caller_dir = pathlib.Path(request.node.fspath).parent
|
||||
module_path = caller_dir.parent / inputs_name
|
||||
return import_module_from_path("inputs", os.fspath(module_path))
|
||||
2
tox.ini
2
tox.ini
|
|
@ -25,7 +25,7 @@ deps =
|
|||
tox-backticks
|
||||
|
||||
setenv =
|
||||
LINTABLES = osbuild/ assemblers/* devices/* inputs/* mounts/* runners/* sources/*.* stages/*.* stages/test/*.py sources/test/*.py test/ `find ./tools ! -name "*.sh" -type f`
|
||||
LINTABLES = osbuild/ assemblers/* devices/* inputs/*.* mounts/* runners/* sources/*.* stages/*.* inputs/test/*.py stages/test/*.py sources/test/*.py test/ `find ./tools ! -name "*.sh" -type f`
|
||||
TYPEABLES = osbuild
|
||||
TYPEABLES_STRICT = ./osbuild/main_cli.py
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue