Added python-eventlet 0.15.2 for Ubuntu 14.04
[packages/trusty/python-eventlet.git] / eventlet / tests / greenpipe_test_with_statement.py
diff --git a/eventlet/tests/greenpipe_test_with_statement.py b/eventlet/tests/greenpipe_test_with_statement.py
new file mode 100644 (file)
index 0000000..c0491b3
--- /dev/null
@@ -0,0 +1,25 @@
+from __future__ import with_statement
+
+import os
+
+from eventlet import greenio
+from tests import LimitedTestCase
+
+
+class TestGreenPipeWithStatement(LimitedTestCase):
+    def test_pipe_context(self):
+        # ensure using a pipe as a context actually closes it.
+        r, w = os.pipe()
+
+        r = greenio.GreenPipe(r)
+        w = greenio.GreenPipe(w, 'w')
+
+        with r:
+            pass
+
+        assert r.closed and not w.closed
+
+        with w as f:
+            assert f == w
+
+        assert r.closed and w.closed