Moved GreenPipe context unit test into separate file. Skip that test in Python versions less than 2.5
This commit is contained in:
@@ -483,26 +483,6 @@ class TestGreenIo(LimitedTestCase):
|
||||
|
||||
gt.wait()
|
||||
|
||||
def test_pipe_context(self):
|
||||
# ensure using a pipe as a context actually closes it.
|
||||
r, w = os.pipe()
|
||||
|
||||
r = os.fdopen(r)
|
||||
w = os.fdopen(w, 'w')
|
||||
|
||||
r = greenio.GreenPipe(r)
|
||||
w = greenio.GreenPipe(w)
|
||||
|
||||
with r:
|
||||
pass
|
||||
|
||||
assert r.closed and not w.closed
|
||||
|
||||
with w as f:
|
||||
assert f == w
|
||||
|
||||
assert r.closed and w.closed
|
||||
|
||||
|
||||
class TestGreenIoLong(LimitedTestCase):
|
||||
TEST_TIMEOUT=10 # the test here might take a while depending on the OS
|
||||
|
||||
28
tests/greenpipe_test_with_statement.py
Normal file
28
tests/greenpipe_test_with_statement.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from __future__ import with_statement
|
||||
|
||||
import os
|
||||
|
||||
from tests import LimitedTestCase
|
||||
|
||||
from eventlet import greenio
|
||||
|
||||
class TestGreenPipeWithStatement(LimitedTestCase):
|
||||
def test_pipe_context(self):
|
||||
# ensure using a pipe as a context actually closes it.
|
||||
r, w = os.pipe()
|
||||
|
||||
r = os.fdopen(r)
|
||||
w = os.fdopen(w, 'w')
|
||||
|
||||
r = greenio.GreenPipe(r)
|
||||
w = greenio.GreenPipe(w)
|
||||
|
||||
with r:
|
||||
pass
|
||||
|
||||
assert r.closed and not w.closed
|
||||
|
||||
with w as f:
|
||||
assert f == w
|
||||
|
||||
assert r.closed and w.closed
|
||||
@@ -10,7 +10,7 @@ if parent_dir not in sys.path:
|
||||
|
||||
# hacky hacks: skip test__api_timeout when under 2.4 because otherwise it SyntaxErrors
|
||||
if sys.version_info < (2,5):
|
||||
argv = sys.argv + ["--exclude=.*timeout_test_with_statement.*"]
|
||||
argv = sys.argv + ["--exclude=.*_with_statement.*"]
|
||||
else:
|
||||
argv = sys.argv
|
||||
|
||||
|
||||
Reference in New Issue
Block a user