X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=eventlet%2Ftests%2Fgreenpipe_test_with_statement.py;fp=eventlet%2Ftests%2Fgreenpipe_test_with_statement.py;h=c0491b3fd1454b56611bfd6582a6d37c8e186816;hb=a7790d9c6e32b6ce02cf489d91c232e7b4d31161;hp=0000000000000000000000000000000000000000;hpb=70992db4bef26426213a8eae488be377cdd655ae;p=packages%2Ftrusty%2Fpython-eventlet.git diff --git a/eventlet/tests/greenpipe_test_with_statement.py b/eventlet/tests/greenpipe_test_with_statement.py new file mode 100644 index 0000000..c0491b3 --- /dev/null +++ b/eventlet/tests/greenpipe_test_with_statement.py @@ -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