From 55072cde9f79ff22f8fb98d665f9af6d10c18573 Mon Sep 17 00:00:00 2001 From: mercael91 Date: Sat, 24 Oct 2026 11:56:00 +0300 Subject: [PATCH 1/4] Add assertion messages to classes checks batch 2 and regression test Signed-off-by: mercael --- checks/classes/classes7.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checks/classes/classes7.py b/checks/classes/classes7.py index c269eff..0ab6652 100644 --- a/checks/classes/classes7.py +++ b/checks/classes/classes7.py @@ -1,3 +1,3 @@ assert g.greet() == "Hello, Alice!", f"got {g.greet()!r}" -assert Greeter("Bob").greet() == "Hello, Bob!" +assert Greeter("Bob").greet() == "Hello, Bob!", f"got {Greeter('Bob').greet()!r}" print("classes7 ✓") From 91596e43338046da4ea2fa91d31b83ec532025f9 Mon Sep 17 00:00:00 2001 From: mercael91 Date: Sat, 24 Oct 2026 11:56:01 +0300 Subject: [PATCH 2/4] Add assertion messages to classes checks batch 2 and regression test Signed-off-by: mercael --- checks/classes/classes8.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checks/classes/classes8.py b/checks/classes/classes8.py index cbac6c4..1a19121 100644 --- a/checks/classes/classes8.py +++ b/checks/classes/classes8.py @@ -1,3 +1,3 @@ assert str(book) == "Book: 1984 by Orwell", f"got {str(book)!r}" -assert str(Book("Dune", "Herbert")) == "Book: Dune by Herbert" +assert str(Book("Dune", "Herbert")) == "Book: Dune by Herbert", f"got {str(Book('Dune', 'Herbert'))!r}" print("classes8 ✓") From 5d689d74ccb919b0c4e44fd8526e04b57d5ded3e Mon Sep 17 00:00:00 2001 From: mercael91 Date: Sat, 24 Oct 2026 11:56:03 +0300 Subject: [PATCH 3/4] Add assertion messages to classes checks batch 2 and regression test Signed-off-by: mercael --- checks/classes/classes9.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/checks/classes/classes9.py b/checks/classes/classes9.py index 63dca06..4f7ce5a 100644 --- a/checks/classes/classes9.py +++ b/checks/classes/classes9.py @@ -1,4 +1,4 @@ assert repr(c) == "Color(r=255, g=128, b=0)", f"got {repr(c)!r}" -assert str(c) == "rgb(255, 128, 0)" -assert repr(Color(0, 0, 0)) == "Color(r=0, g=0, b=0)" +assert str(c) == "rgb(255, 128, 0)", f"got {str(c)!r}" +assert repr(Color(0, 0, 0)) == "Color(r=0, g=0, b=0)", f"got {repr(Color(0, 0, 0))!r}" print("classes9 ✓") From 0b0bdef55879a2b44f4f0655b8d0ad2454230011 Mon Sep 17 00:00:00 2001 From: mercael91 Date: Sat, 24 Oct 2026 11:56:04 +0300 Subject: [PATCH 4/4] Add assertion messages to classes checks batch 2 and regression test Signed-off-by: mercael --- tests/test_classes_assertion_messages.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/test_classes_assertion_messages.py diff --git a/tests/test_classes_assertion_messages.py b/tests/test_classes_assertion_messages.py new file mode 100644 index 0000000..c28c008 --- /dev/null +++ b/tests/test_classes_assertion_messages.py @@ -0,0 +1,23 @@ +import ast +import pathlib + + +CHECKS_DIR = pathlib.Path(__file__).resolve().parent.parent / "checks" / "classes" +BATCH = ["classes7.py", "classes8.py", "classes9.py"] + + +def _asserts_without_msg(path): + tree = ast.parse(path.read_text(encoding="utf-8")) + missing = [] + for node in ast.walk(tree): + if isinstance(node, ast.Assert) and node.msg is None: + missing.append(node.lineno) + return missing + + +def test_batch_asserts_have_messages(): + for name in BATCH: + path = CHECKS_DIR / name + assert path.exists(), f"missing check file: {path}" + missing = _asserts_without_msg(path) + assert not missing, f"{name} has asserts without messages at lines {missing}"