Skip to content

Commit 5959ef5

Browse files
committed
tests: Add templates rendenring tests using inline-snapshot
Issue-150: #150
1 parent 18283b0 commit 5959ef5

File tree

93 files changed

+14301
-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

+14301
-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
@@ -87,6 +87,8 @@ dev-dependencies = [
8787
"pytest-cov>=5.0",
8888
"pytest-randomly>=3.15",
8989
"pytest-xdist>=3.6",
90+
"beautifulsoup4>=4.12",
91+
"inline-snapshot>=0.18",
9092
"mypy>=1.10",
9193
"types-markdown>=3.6",
9294
"types-pyyaml>=6.0",
@@ -104,4 +106,7 @@ dev-dependencies = [
104106
"mkdocs-minify-plugin>=0.8",
105107
# YORE: EOL 3.10: Remove line.
106108
"tomli>=2.0; python_version < '3.11'",
107-
]
109+
]
110+
111+
[tool.inline-snapshot]
112+
storage-dir = "tests/snapshots"

0 commit comments

Comments
 (0)