Skip to content

Instantly share code, notes, and snippets.

@goujonbe
Last active October 31, 2020 16:23
Show Gist options
  • Save goujonbe/4acfd9ad1c0a51dcc690ec59eceaaabf to your computer and use it in GitHub Desktop.
Save goujonbe/4acfd9ad1c0a51dcc690ec59eceaaabf to your computer and use it in GitHub Desktop.
Gist that is part of a tutorial on Pytest features.
def test_translate_animal_names(caplog):
animals_in_french = ["lapin", "grenouille", "cheval"]
french_english_translation = {
"lapin": "rabbit",
"cheval": "horse"
}
animals_in_english = translate_animal_names(
animals_in_french,
french_english_translation
)
assert animals_in_english == ["rabbit", "horse"]
assert caplog.record_tuples == [
(
"root",
logging.WARNING,
"'grenouille' is not present in the translations provided."
)
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment