Skip to content

Commit

Permalink
tests: Add templates rendenring tests using inline-snapshot
Browse files Browse the repository at this point in the history
Issue-150: #150
  • Loading branch information
pawamoy committed Dec 23, 2024
1 parent 6db0e20 commit 662d798
Show file tree
Hide file tree
Showing 93 changed files with 12,932 additions and 3 deletions.
10 changes: 8 additions & 2 deletions duties.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,20 +217,26 @@ def coverage(ctx: Context) -> None:


@duty
def test(ctx: Context, *cli_args: str, match: str = "") -> None:
def test(ctx: Context, *cli_args: str, match: str = "", snapshot: str = "report") -> None:
"""Run the test suite.
Parameters:
match: A pytest expression to filter selected tests.
snapshot: Whether to "create", "fix", "trim", or "update" snapshots.
"""
py_version = f"{sys.version_info.major}{sys.version_info.minor}"
os.environ["COVERAGE_FILE"] = f".coverage.{py_version}"
args = list(cli_args)
if snapshot == "disable" or not snapshot:
args = ["-n", "auto", "--inline-snapshot=disable"]
else:
args = [f"--inline-snapshot={snapshot}"]
ctx.run(
tools.pytest(
"tests",
config_file="config/pytest.ini",
select=match,
color="yes",
).add_args("-n", "auto", *cli_args),
).add_args(*args),
title=pyprefix("Running tests"),
)
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ dev = [
"pytest-cov>=5.0",
"pytest-randomly>=3.15",
"pytest-xdist>=3.6",
"beautifulsoup4>=4.12",
"inline-snapshot>=0.18",
"mypy>=1.10",
"types-markdown>=3.6",
"types-pyyaml>=6.0",
Expand All @@ -112,4 +114,7 @@ dev = [
"mkdocs-minify-plugin>=0.8",
# YORE: EOL 3.10: Remove line.
"tomli>=2.0; python_version < '3.11'",
]
]

[tool.inline-snapshot]
storage-dir = "tests/snapshots"
Loading

0 comments on commit 662d798

Please sign in to comment.