]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Added test_streaming_callback_with_data_in_buffer to iostream_test.py
authorOmri Bahumi <omrib@everything.me>
Thu, 28 Feb 2013 17:49:50 +0000 (19:49 +0200)
committerOmri Bahumi <omrib@everything.me>
Thu, 28 Feb 2013 17:49:50 +0000 (19:49 +0200)
tornado/test/iostream_test.py

index 79a2b730efe4b1f5e092bd029e8fb53d0bf489f7..bb4796d6f225df889b29f79eeace9f37e7464b69 100644 (file)
@@ -145,6 +145,22 @@ class TestIOStreamMixin(object):
         listener.close()
         return streams
 
+    def test_streaming_callback_with_data_in_buffer(self):
+        server, client = self.make_iostream_pair()
+        client.write("abcd\r\nefgh")
+        server.read_until("\r\n", self.stop)
+        data = self.wait()
+        self.assertEqual(data, "abcd\r\n")
+        def closed_callback(chunk):
+            self.fail()
+        server.read_until_close(callback=closed_callback,
+                                streaming_callback=self.stop)
+        self.io_loop.add_timeout(self.io_loop.time() + 0.01, self.stop)
+        data = self.wait()
+        self.assertEqual(data, "efgh")
+        server.close()
+        client.close()
+
     def test_write_zero_bytes(self):
         # Attempting to write zero bytes should run the callback without
         # going into an infinite loop.