Commits

Anonymous committed 9d31a27

new test

Comments (0)

Files changed (1)

test/websocket_test.py

+import gevent
 from gevent.queue import Queue
 import pytest
 from mock import Mock, patch
         inbound._get_next_message()
         assert recv_mock.called
         assert queue.qsize() == 1
+
+
+def test_inbound_run_exception(inbound):
+    with patch.object(inbound, "_get_next_message") as gnm:
+        def f():
+            raise Exception("test_exception")
+
+        gnm.side_effect = f
+
+        class TooLong(Exception):
+            pass
+
+        # terminate test of endless loop using timeout
+        with gevent.Timeout(.1, TooLong):
+            try:
+                inbound._run()
+            except TooLong:
+                pass