From 3f45c87186972d7d9a17dc69095ad5cda5f0bcdc Mon Sep 17 00:00:00 2001 From: ivanharvard Date: Wed, 25 Feb 2026 01:02:48 -0500 Subject: [PATCH 1/2] convert to raw before truncation and improve list output --- check50/_api.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/check50/_api.py b/check50/_api.py index cce0531..6e2ce9e 100644 --- a/check50/_api.py +++ b/check50/_api.py @@ -425,12 +425,10 @@ class Missing(Failure): """ def __init__(self, missing_item, collection, help=None): - if isinstance(collection, list): - collection = _process_list(collection, _raw) - + missing_item, collection = _raw(missing_item), _raw(collection) truncated_collection = _truncate(collection, missing_item) - super().__init__(rationale=_("Did not find {} in {}").format(_raw(missing_item), _raw(truncated_collection)), help=help) + super().__init__(rationale=_("Did not find {} in {}").format(missing_item, truncated_collection), help=help) if missing_item == EOF: missing_item = "EOF" @@ -461,16 +459,17 @@ class Mismatch(Failure): """ def __init__(self, expected, actual, help=None): + expected, actual = _raw(expected), _raw(actual) expected, actual = _truncate(expected, actual), _truncate(actual, expected) rationale = _("expected: {}\n actual: {}").format( - _raw(expected), - _raw(actual) + expected, + actual ) super().__init__(rationale=rationale, help=help) - self.payload.update({"expected": _raw(expected), "actual": _raw(actual)}) + self.payload.update({"expected": expected, "actual": actual}) def hidden(failure_rationale): @@ -609,9 +608,10 @@ def _raw(s): return "EOF" elif s == TIMEOUT: return "TIMEOUT" - - s = f'"{repr(str(s))[1:-1]}"' - return s + elif isinstance(s, list): + return "[{}]".format(", ".join(_raw(item) for item in s)) + + return repr(s) def _copy(src, dst): From a73be89e014bbd7f19a0a0f6384af7c79f5bbb43 Mon Sep 17 00:00:00 2001 From: ivanharvard Date: Wed, 25 Feb 2026 01:36:53 -0500 Subject: [PATCH 2/2] update tests --- tests/check50_tests.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/check50_tests.py b/tests/check50_tests.py index 4c3dc1e..61d2013 100644 --- a/tests/check50_tests.py +++ b/tests/check50_tests.py @@ -99,8 +99,8 @@ def test_with_empty_file(self): process.expect_exact("foo.py exists") process.expect_exact(":(") process.expect_exact("prints hello") - process.expect_exact("expected: \"hello\"") - process.expect_exact("actual: \"\"") + process.expect_exact("expected: 'hello'") + process.expect_exact("actual: ''") process.close(force=True) @@ -146,8 +146,8 @@ def test_with_empty_file(self): process.expect_exact("foo.py exists") process.expect_exact(":(") process.expect_exact("prints hello name") - process.expect_exact("expected: \"hello bar\"") - process.expect_exact("actual: \"\"") + process.expect_exact("expected: 'hello bar'") + process.expect_exact("actual: ''") process.close(force=True) def test_with_correct_file(self):