From 3a23edd7aa2a33c47ce9d4ff0167d80bee26b300 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Tue, 17 Oct 2017 07:55:03 +0000 Subject: [PATCH] Clearer selftest errors on disconnection Catch EOFError in the selftest framework and emit a message indicating what happened. --- mudpy/tests/selftest.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/mudpy/tests/selftest.py b/mudpy/tests/selftest.py index 15d7366..500356f 100644 --- a/mudpy/tests/selftest.py +++ b/mudpy/tests/selftest.py @@ -256,9 +256,17 @@ def main(): test_start = time.time() for conversant, question, answer in test: print("luser%s waiting for: %s" % (conversant, question)) - index, match, received = lusers[conversant].expect( - [re.compile(question.encode("utf-8"), flags=re.DOTALL)], 5) - captures[conversant] += received.decode("utf-8") + try: + index, match, received = lusers[conversant].expect( + [re.compile(question.encode("utf-8"), flags=re.DOTALL)], 5) + captures[conversant] += received.decode("utf-8") + except EOFError: + print("ERROR: luser%s premature disconnection expecting:\n\n" + "%s\n\n" + "Check the end of capture_%s.log for received data." + % (conversant, question, conversant)) + success = False + break try: captures[conversant] += lusers[ conversant].read_very_eager().decode("utf-8") -- 2.11.0