Skip to content

Instantly share code, notes, and snippets.

@Luttik
Last active September 21, 2020 15:09
Show Gist options
  • Select an option

  • Save Luttik/a82c2df43a5399d4288cec985ac7a874 to your computer and use it in GitHub Desktop.

Select an option

Save Luttik/a82c2df43a5399d4288cec985ac7a874 to your computer and use it in GitHub Desktop.
pytest-locker example template
# templates/welcome.jinja, i.e. the template used in the test.
Hi {{user.name}},
Welcome to this test.
Kind regards,
Tester
# test/unit/test_template.py, i.e. the test
def test_template(locker: Locker) -> None: # Typehints are optional of course
template = get_template("welcome.jinja")
test_user = User(name="Alice")
result = template.render(user=test_user)
locker.lock(result)
# .pytest-locker/test.unit.test_template.1.txt, i.e. the output that is locked (if accepted).
Hi Alice,
Welcome to this test.
Kind regards,
Tester
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment