c0491b3fd1454b56611bfd6582a6d37c8e186816
[packages/trusty/python-eventlet.git] / python-eventlet / tests / greenpipe_test_with_statement.py
1 from __future__ import with_statement
2
3 import os
4
5 from eventlet import greenio
6 from tests import LimitedTestCase
7
8
9 class TestGreenPipeWithStatement(LimitedTestCase):
10     def test_pipe_context(self):
11         # ensure using a pipe as a context actually closes it.
12         r, w = os.pipe()
13
14         r = greenio.GreenPipe(r)
15         w = greenio.GreenPipe(w, 'w')
16
17         with r:
18             pass
19
20         assert r.closed and not w.closed
21
22         with w as f:
23             assert f == w
24
25         assert r.closed and w.closed