From: Jeremy Stanley Date: Tue, 17 Oct 2017 07:55:03 +0000 (+0000) Subject: Clearer selftest errors on disconnection X-Git-Tag: 0.0.1~127 X-Git-Url: https://mudpy.org/gitweb?p=mudpy.git;a=commitdiff_plain;h=3a23edd7aa2a33c47ce9d4ff0167d80bee26b300;ds=sidebyside Clearer selftest errors on disconnection Catch EOFError in the selftest framework and emit a message indicating what happened. --- 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")