~reviewer/hello-hut

ref: 80fead3c8b8b3eaf0faa2694b6d88ad9ec31fd6e hello-hut/tests/test_phrasebook.py -rw-r--r-- 628 bytes
80fead3c — Ines Moreau config: do not crash when $HOME is unset 5 months 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)