From 0f70160a4b49ca58d0b34c835cac26368e0b22fe Mon Sep 17 00:00:00 2001 From: Tom O'Hara Date: Mon, 11 Sep 2023 20:37:49 -0500 Subject: [PATCH] fleshes out do_assert and skips if not debugging --- mezcla/tests/test_unittest_wrapper.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/mezcla/tests/test_unittest_wrapper.py b/mezcla/tests/test_unittest_wrapper.py index 335edc1e..5c149868 100644 --- a/mezcla/tests/test_unittest_wrapper.py +++ b/mezcla/tests/test_unittest_wrapper.py @@ -55,6 +55,7 @@ class TestIt2: """Class for API usage""" + @pytest.mark.skipif(not debug.debugging(1), reason="Must be debugging") ## TODO: ## @pytest_fixture_wrapper ## @trap_exception @@ -68,13 +69,22 @@ class SubTestIt(TestWrapper): # sti = SubTestIt() captured_trace = "" + message = "Good math" try: - sti.do_assert(False) + sti.do_assert(2 + 2 == 5, message) # Orwell's condition except AssertionError: pass captured_trace = capsys.readouterr().err debug.trace_expr(5, captured_trace) - assert(my_re.search(r"\bdo_assert\b", captured_trace)) + + # The condition and message should be displayed + assert("2 + 2 == 5" in captured_trace) + assert(message in captured_trace) + + # Make sure stuff properly stripped (i.e., message arg and comment) + assert(not "message" in captured_trace) + assert(not "Orwell" in captured_trace) + assert(not my_re.search(r"\bdo_assert\b", captured_trace)) return #------------------------------------------------------------------------