Discussion forum for David Beazley

Typo in unit tests results in hanging


While hacking on curio I noticed that a simple typo (something resulting in NameError) either in the unit tests or the curio code itself in some circumstances may cause the tests to hang indefinitely. When that happens and I hit CTRL+C the traceback gives no clue about what the real problem was.
Example to reproduce:

diff --git a/tests/test_socket.py b/tests/test_socket.py
index b6c3695..a6f4138 100644
--- a/tests/test_socket.py
+++ b/tests/test_socket.py
@@ -27,7 +27,7 @@ def test_tcp_echo(kernel):
             results.append(('handler', data))
             await client.writeable()
-            await client.sendall(data)
+            await client.sendallxxx(data)
         results.append('handler done')
         await client.close()

Am I supposed to run tests in debug mode or something?


It turns out this is my fault: I had to add -s option to pytest command line.


-s definitely helps get an idea of what’s going on, but the curio testsuite has a few rough edges like this :-(. Curio’s current way of handling task crashes makes it really easy for errors to pass silently – I kind of wish that any unhandled task crash killed the event loop, instead of only crashes in the main task. The test suite also uses sleep() too much… incrementally cleaning those up would be a good task for someone who wants to do something relatively straightforward but useful :-).