Clearer selftest errors on disconnection
authorJeremy Stanley <fungi@yuggoth.org>
Tue, 17 Oct 2017 07:55:03 +0000 (07:55 +0000)
committerJeremy Stanley <fungi@yuggoth.org>
Thu, 9 Nov 2017 05:34:17 +0000 (05:34 +0000)
Catch EOFError in the selftest framework and emit a message
indicating what happened.

mudpy/tests/selftest.py

index 15d7366..500356f 100644 (file)
@@ -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")