Last active
September 21, 2020 15:09
-
-
Save Luttik/a82c2df43a5399d4288cec985ac7a874 to your computer and use it in GitHub Desktop.
pytest-locker example template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # templates/welcome.jinja, i.e. the template used in the test. | |
| Hi {{user.name}}, | |
| Welcome to this test. | |
| Kind regards, | |
| Tester |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # .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