summaryrefslogtreecommitdiff
path: root/tests/greenpipe_test_with_statement.py
blob: c0491b3fd1454b56611bfd6582a6d37c8e186816 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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