Compare commits

..
2 Commits
Author SHA1 Message Date
arcanis 14dd97f2ca move root conftest into pytest plugins 2026-07-16 16:30:38 +03:00
arcanis bfd3148617 some play with renaming 2026-07-16 14:40:54 +03:00
14 changed files with 61 additions and 20 deletions
+5
View File
@@ -0,0 +1,5 @@
[tool.bandit]
skips = [
"B404",
"B603",
]
-3
View File
@@ -1,3 +0,0 @@
skips:
- B404
- B603
-7
View File
@@ -1,7 +0,0 @@
[pytest]
addopts = --cov=ahriman --cov-report=term-missing:skip-covered --no-cov-on-fail --cov-fail-under=100 --spec
asyncio_default_fixture_loop_scope = function
asyncio_mode = auto
pythonpath = tests
resource-path.directory-name-test-resources = ../../tests/testresources
spec_test_format = {result} {docstring_summary}
+8
View File
@@ -0,0 +1,8 @@
[pytest]
addopts = [
"--spec",
]
asyncio_default_fixture_loop_scope = "function"
asyncio_mode = "auto"
"resource-path.directory-name-test-resources" = "../../tests/testresources"
spec_test_format = "{result} {docstring_summary}"
+3 -3
View File
@@ -20,9 +20,9 @@ build() {
npm --prefix "frontend" install --cache "$srcdir/npm-cache"
npm --prefix "frontend" run build
python -m build --wheel --no-isolation ahriman-core
python -m build --wheel --no-isolation ahriman-triggers
python -m build --wheel --no-isolation ahriman-web
python -m build --wheel --no-isolation "ahriman-core"
python -m build --wheel --no-isolation "ahriman-triggers"
python -m build --wheel --no-isolation "ahriman-web"
}
package_ahriman() {
+3 -2
View File
@@ -44,9 +44,9 @@ docs = [
"sphinx-rtd-theme>=1.1.1", # https://stackoverflow.com/a/74355734
]
tests = [
"coverage",
"pytest",
"pytest-aiohttp",
"pytest-cov",
"pytest-helpers-namespace",
"pytest-mock",
"pytest-resource-path",
@@ -62,9 +62,10 @@ exclude = [
"/recipes",
"/tools",
"tests",
"/.bandit.yml",
"/.bandit.toml",
"/.dockerignore",
"/.pylint.toml",
"/.pytest.toml",
"/.readthedocs.yml",
"/conftest.py",
"/github-logo.png",
View File
+1
View File
@@ -0,0 +1 @@
"""Repository-local pytest plugins."""
@@ -41,7 +41,6 @@ T = TypeVar("T")
# helpers
# https://stackoverflow.com/a/21611963
@pytest.helpers.register
def anyvar(cls: type[T], strict: bool = False) -> T:
"""
any value helper for mocker calls check
@@ -73,7 +72,6 @@ def anyvar(cls: type[T], strict: bool = False) -> T:
return AnyVar()
@pytest.helpers.register
def get_package_status(package: Package) -> dict[str, Any]:
"""
helper to extract package status from package
@@ -87,7 +85,6 @@ def get_package_status(package: Package) -> dict[str, Any]:
return {"status": BuildStatusEnum.Unknown.value, "package": package.view()}
@pytest.helpers.register
def get_package_status_extended(package: Package) -> dict[str, Any]:
"""
helper to extract package status from package
@@ -101,7 +98,6 @@ def get_package_status_extended(package: Package) -> dict[str, Any]:
return {"status": BuildStatus().view(), "package": package.view()}
@pytest.helpers.register
def import_error(package: str, components: list[str], mocker: MockerFixture) -> MagicMock:
"""
mock import error
@@ -125,6 +121,15 @@ def import_error(package: str, components: list[str], mocker: MockerFixture) ->
return mocker.patch.object(builtins, "__import__", test_import)
@pytest.hookimpl(trylast=True)
def pytest_configure() -> None:
"""
register helpers after pytest-helpers-namespace has initialized
"""
for helper in (anyvar, get_package_status, get_package_status_extended, import_error):
pytest.helpers.register(helper)
# generic fixtures
@pytest.fixture(autouse=True)
def register_log_context() -> None:
+18
View File
@@ -0,0 +1,18 @@
[build-system]
requires = [
"hatchling",
]
build-backend = "hatchling.build"
[project]
name = "ahriman-pytest-plugins"
version = "1"
classifiers = [
"Framework :: Pytest",
]
[project.entry-points.pytest11]
ahriman-fixtures = "ahriman_fixtures"
[tool.hatch.build.targets.wheel]
packages = ["."]
+14 -1
View File
@@ -28,7 +28,7 @@ autopep8 = [
]
bandit = [
"--configfile",
".bandit.yml",
".bandit.toml",
]
manpage = [
"--author",
@@ -335,11 +335,17 @@ dependency_groups = [
]
deps = [
{ replace = "ref", of = ["project", "extras"], extend = true },
"./tools/pytest_plugins",
]
pip_pre = true
set_env.CFLAGS = "-Wno-unterminated-string-initialization"
commands = [
[
"coverage",
"run",
"--source",
"ahriman",
"-m",
"pytest",
"tests/test_tests.py",
"ahriman-core/tests",
@@ -347,6 +353,13 @@ commands = [
"ahriman-web/tests",
{ replace = "posargs", extend = true },
],
[
"coverage",
"report",
"--show-missing",
"--skip-covered",
"--fail-under=100",
],
]
[env.version]