Skip to content

Commit c8f1a77

Browse files
committed
tests: Add templates rendenring tests using inline-snapshot
Issue-150: #150
1 parent e493663 commit c8f1a77

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

+8-2
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

+6-1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ dev = [
9090
"pytest-cov>=5.0",
9191
"pytest-randomly>=3.15",
9292
"pytest-xdist>=3.6",
93+
"beautifulsoup4>=4.12.3",
94+
"inline-snapshot>=0.18",
9395
"mypy>=1.10",
9496
"types-markdown>=3.6",
9597
"types-pyyaml>=6.0",
@@ -107,4 +109,7 @@ dev = [
107109
"mkdocs-minify-plugin>=0.8",
108110
# YORE: EOL 3.10: Remove line.
109111
"tomli>=2.0; python_version < '3.11'",
110-
]
112+
]
113+
114+
[tool.inline-snapshot]
115+
storage-dir = "tests/snapshots"

0 commit comments

Comments
 (0)