~reviewer/hello-hut

ref: e9c5dfadb593e1030b54e956c55e0cb43ef2c81d hello-hut/tests/test_phrasebook.py -rw-r--r-- 628 bytes
e9c5dfad — Noor Haddad cli: add --lang to pick the greeting language 22 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
"""Snapshot test: every line of fixtures/phrasebook.txt must round-trip."""

import pathlib
import unittest

from hello_hut.greetings import greet

FIXTURE = pathlib.Path(__file__).parent / "fixtures" / "phrasebook.txt"


class PhrasebookTest(unittest.TestCase):
    def test_phrasebook(self):
        for line in FIXTURE.read_text(encoding="utf-8").splitlines():
            if not line or line.startswith("#"):
                continue
            style, name, expected = line.split("\t")
            with self.subTest(name=name, style=style):
                self.assertEqual(greet(name, shout=(style == "shout")), expected)