krz/daily-poem

Poetry emailed, at your will.

clone: git clone https://gitbay.org/krz/daily-poem.git

215f74e70653a33420a681812d0b1405d2551407

verified · cmc

author: Christian Cleberg <hello@cleberg.net> · 2026-08-23T02:20:34Z

Lift the test fixture out of the class

RUF012: a list as a class attribute is a mutable default. I had linted only
main.py locally; the action lints the repo.
 tests/test_main.py | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/tests/test_main.py b/tests/test_main.py
index cea5ba9..794e15a 100644
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -24,21 +24,22 @@ class TestBuildMessage(unittest.TestCase):
         self.assertIn("one\ntwo", msg.get_payload())
 
 
+PAYLOAD = [
+    {
+        "title": "Sonnet",
+        "author": "Anon",
+        "linecount": "2",
+        "lines": ["first line", "second line"],
+    }
+]
+
+
 class TestFetchPoem(unittest.TestCase):
     """PoetryDB is stubbed: the test covers the shape this code expects from it,
     not the service being up."""
 
-    PAYLOAD = [
-        {
-            "title": "Sonnet",
-            "author": "Anon",
-            "linecount": "2",
-            "lines": ["first line", "second line"],
-        }
-    ]
-
     def test_fields_are_extracted_and_lines_joined(self):
-        with patch("main.requests.get", return_value=FakeResponse(self.PAYLOAD)):
+        with patch("main.requests.get", return_value=FakeResponse(PAYLOAD)):
             title, author, line_count, lines = fetch_poem()
 
         self.assertEqual(title, "Sonnet")