mirror of
https://github.com/arcan1s/ahriman.git
synced 2026-08-20 15:27:26 +00:00
Compare commits
2
Commits
7a2d8299ad
...
14dd97f2ca
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
14dd97f2ca | ||
|
|
bfd3148617 |
@@ -0,0 +1,5 @@
|
|||||||
|
[tool.bandit]
|
||||||
|
skips = [
|
||||||
|
"B404",
|
||||||
|
"B603",
|
||||||
|
]
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
skips:
|
|
||||||
- B404
|
|
||||||
- B603
|
|
||||||
@@ -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}
|
|
||||||
@@ -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
@@ -20,9 +20,9 @@ build() {
|
|||||||
npm --prefix "frontend" install --cache "$srcdir/npm-cache"
|
npm --prefix "frontend" install --cache "$srcdir/npm-cache"
|
||||||
npm --prefix "frontend" run build
|
npm --prefix "frontend" run build
|
||||||
|
|
||||||
python -m build --wheel --no-isolation ahriman-core
|
python -m build --wheel --no-isolation "ahriman-core"
|
||||||
python -m build --wheel --no-isolation ahriman-triggers
|
python -m build --wheel --no-isolation "ahriman-triggers"
|
||||||
python -m build --wheel --no-isolation ahriman-web
|
python -m build --wheel --no-isolation "ahriman-web"
|
||||||
}
|
}
|
||||||
|
|
||||||
package_ahriman() {
|
package_ahriman() {
|
||||||
|
|||||||
+3
-2
@@ -44,9 +44,9 @@ docs = [
|
|||||||
"sphinx-rtd-theme>=1.1.1", # https://stackoverflow.com/a/74355734
|
"sphinx-rtd-theme>=1.1.1", # https://stackoverflow.com/a/74355734
|
||||||
]
|
]
|
||||||
tests = [
|
tests = [
|
||||||
|
"coverage",
|
||||||
"pytest",
|
"pytest",
|
||||||
"pytest-aiohttp",
|
"pytest-aiohttp",
|
||||||
"pytest-cov",
|
|
||||||
"pytest-helpers-namespace",
|
"pytest-helpers-namespace",
|
||||||
"pytest-mock",
|
"pytest-mock",
|
||||||
"pytest-resource-path",
|
"pytest-resource-path",
|
||||||
@@ -62,9 +62,10 @@ exclude = [
|
|||||||
"/recipes",
|
"/recipes",
|
||||||
"/tools",
|
"/tools",
|
||||||
"tests",
|
"tests",
|
||||||
"/.bandit.yml",
|
"/.bandit.toml",
|
||||||
"/.dockerignore",
|
"/.dockerignore",
|
||||||
"/.pylint.toml",
|
"/.pylint.toml",
|
||||||
|
"/.pytest.toml",
|
||||||
"/.readthedocs.yml",
|
"/.readthedocs.yml",
|
||||||
"/conftest.py",
|
"/conftest.py",
|
||||||
"/github-logo.png",
|
"/github-logo.png",
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
"""Repository-local pytest plugins."""
|
||||||
@@ -41,7 +41,6 @@ T = TypeVar("T")
|
|||||||
|
|
||||||
# helpers
|
# helpers
|
||||||
# https://stackoverflow.com/a/21611963
|
# https://stackoverflow.com/a/21611963
|
||||||
@pytest.helpers.register
|
|
||||||
def anyvar(cls: type[T], strict: bool = False) -> T:
|
def anyvar(cls: type[T], strict: bool = False) -> T:
|
||||||
"""
|
"""
|
||||||
any value helper for mocker calls check
|
any value helper for mocker calls check
|
||||||
@@ -73,7 +72,6 @@ def anyvar(cls: type[T], strict: bool = False) -> T:
|
|||||||
return AnyVar()
|
return AnyVar()
|
||||||
|
|
||||||
|
|
||||||
@pytest.helpers.register
|
|
||||||
def get_package_status(package: Package) -> dict[str, Any]:
|
def get_package_status(package: Package) -> dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
helper to extract package status from package
|
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()}
|
return {"status": BuildStatusEnum.Unknown.value, "package": package.view()}
|
||||||
|
|
||||||
|
|
||||||
@pytest.helpers.register
|
|
||||||
def get_package_status_extended(package: Package) -> dict[str, Any]:
|
def get_package_status_extended(package: Package) -> dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
helper to extract package status from package
|
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()}
|
return {"status": BuildStatus().view(), "package": package.view()}
|
||||||
|
|
||||||
|
|
||||||
@pytest.helpers.register
|
|
||||||
def import_error(package: str, components: list[str], mocker: MockerFixture) -> MagicMock:
|
def import_error(package: str, components: list[str], mocker: MockerFixture) -> MagicMock:
|
||||||
"""
|
"""
|
||||||
mock import error
|
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)
|
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
|
# generic fixtures
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def register_log_context() -> None:
|
def register_log_context() -> None:
|
||||||
@@ -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 = ["."]
|
||||||
@@ -28,7 +28,7 @@ autopep8 = [
|
|||||||
]
|
]
|
||||||
bandit = [
|
bandit = [
|
||||||
"--configfile",
|
"--configfile",
|
||||||
".bandit.yml",
|
".bandit.toml",
|
||||||
]
|
]
|
||||||
manpage = [
|
manpage = [
|
||||||
"--author",
|
"--author",
|
||||||
@@ -335,11 +335,17 @@ dependency_groups = [
|
|||||||
]
|
]
|
||||||
deps = [
|
deps = [
|
||||||
{ replace = "ref", of = ["project", "extras"], extend = true },
|
{ replace = "ref", of = ["project", "extras"], extend = true },
|
||||||
|
"./tools/pytest_plugins",
|
||||||
]
|
]
|
||||||
pip_pre = true
|
pip_pre = true
|
||||||
set_env.CFLAGS = "-Wno-unterminated-string-initialization"
|
set_env.CFLAGS = "-Wno-unterminated-string-initialization"
|
||||||
commands = [
|
commands = [
|
||||||
[
|
[
|
||||||
|
"coverage",
|
||||||
|
"run",
|
||||||
|
"--source",
|
||||||
|
"ahriman",
|
||||||
|
"-m",
|
||||||
"pytest",
|
"pytest",
|
||||||
"tests/test_tests.py",
|
"tests/test_tests.py",
|
||||||
"ahriman-core/tests",
|
"ahriman-core/tests",
|
||||||
@@ -347,6 +353,13 @@ commands = [
|
|||||||
"ahriman-web/tests",
|
"ahriman-web/tests",
|
||||||
{ replace = "posargs", extend = true },
|
{ replace = "posargs", extend = true },
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
"coverage",
|
||||||
|
"report",
|
||||||
|
"--show-missing",
|
||||||
|
"--skip-covered",
|
||||||
|
"--fail-under=100",
|
||||||
|
],
|
||||||
]
|
]
|
||||||
|
|
||||||
[env.version]
|
[env.version]
|
||||||
|
|||||||
Reference in New Issue
Block a user