Skip to content

Commit

Permalink
fleshes out do_assert and skips if not debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom O'Hara committed Sep 12, 2023
1 parent b33cfa0 commit 0f70160
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions mezcla/tests/test_unittest_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

#------------------------------------------------------------------------
Expand Down

0 comments on commit 0f70160

Please sign in to comment.