From 4779badd96fb8370e3dfb3eb1f97dbcaafd8cff3 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 14 Jul 2022 20:35:14 -0400 Subject: [PATCH] Add before assert helper and print console bytes on fail --- tests/test_debugger.py | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/tests/test_debugger.py b/tests/test_debugger.py index b5c959b..19b27ba 100644 --- a/tests/test_debugger.py +++ b/tests/test_debugger.py @@ -73,6 +73,22 @@ def spawn( return _spawn +def assert_before( + child, + patts: list[str], + +) -> None: + + before = str(child.before.decode()) + + for patt in patts: + try: + assert patt in before + except AssertionError: + print(before) + raise + + @pytest.fixture( params=[False, True], ids='ctl-c={}'.format, @@ -163,6 +179,8 @@ def do_ctlc( time.sleep(delay) child.sendcontrol('c') + before = str(child.before.decode()) + # TODO: figure out why this makes CI fail.. # if you run this test manually it works just fine.. from conftest import _ci_env @@ -175,8 +193,6 @@ def do_ctlc( # should see the last line on console assert patt in before - before = str(child.before.decode()) - def test_root_actor_bp_forever( spawn, @@ -365,9 +381,15 @@ def test_multi_subactors( # 2nd name_error failure child.expect(r"\(Pdb\+\+\)") - before = str(child.before.decode()) - assert "Attaching to pdb in crashed actor: ('name_error_1'" in before - assert "NameError" in before + + assert_before(child, [ + "Attaching to pdb in crashed actor: ('name_error_1'", + "NameError", + ]) + + # before = str(child.before.decode()) + # assert "Attaching to pdb in crashed actor: ('name_error_1'" in before + # assert "NameError" in before if ctlc: do_ctlc(child)