Skip to content

Commit 662d798

Browse files
committed
tests: Add templates rendenring tests using inline-snapshot
Issue-150: #150
1 parent 6db0e20 commit 662d798

File tree

93 files changed

+12932
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+12932
-3
lines changed

duties.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,20 +217,26 @@ def coverage(ctx: Context) -> None:
217217

218218

219219
@duty
220-
def test(ctx: Context, *cli_args: str, match: str = "") -> None:
220+
def test(ctx: Context, *cli_args: str, match: str = "", snapshot: str = "report") -> None:
221221
"""Run the test suite.
222222
223223
Parameters:
224224
match: A pytest expression to filter selected tests.
225+
snapshot: Whether to "create", "fix", "trim", or "update" snapshots.
225226
"""
226227
py_version = f"{sys.version_info.major}{sys.version_info.minor}"
227228
os.environ["COVERAGE_FILE"] = f".coverage.{py_version}"
229+
args = list(cli_args)
230+
if snapshot == "disable" or not snapshot:
231+
args = ["-n", "auto", "--inline-snapshot=disable"]
232+
else:
233+
args = [f"--inline-snapshot={snapshot}"]
228234
ctx.run(
229235
tools.pytest(
230236
"tests",
231237
config_file="config/pytest.ini",
232238
select=match,
233239
color="yes",
234-
).add_args("-n", "auto", *cli_args),
240+
).add_args(*args),
235241
title=pyprefix("Running tests"),
236242
)

pyproject.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ dev = [
9595
"pytest-cov>=5.0",
9696
"pytest-randomly>=3.15",
9797
"pytest-xdist>=3.6",
98+
"beautifulsoup4>=4.12",
99+
"inline-snapshot>=0.18",
98100
"mypy>=1.10",
99101
"types-markdown>=3.6",
100102
"types-pyyaml>=6.0",
@@ -112,4 +114,7 @@ dev = [
112114
"mkdocs-minify-plugin>=0.8",
113115
# YORE: EOL 3.10: Remove line.
114116
"tomli>=2.0; python_version < '3.11'",
115-
]
117+
]
118+
119+
[tool.inline-snapshot]
120+
storage-dir = "tests/snapshots"

0 commit comments

Comments
 (0)