From 0e69e72d3c6d763fd91793d82f69de3569a1bc93 Mon Sep 17 00:00:00 2001 From: Scott Robinson Date: Thu, 4 Mar 2010 17:27:19 -0600 Subject: [PATCH] Moved GreenPipe context unit test into separate file. Skip that test in Python versions less than 2.5 --- tests/greenio_test.py | 20 ------------------ tests/greenpipe_test_with_statement.py | 28 ++++++++++++++++++++++++++ tests/nosewrapper.py | 2 +- 3 files changed, 29 insertions(+), 21 deletions(-) create mode 100644 tests/greenpipe_test_with_statement.py diff --git a/tests/greenio_test.py b/tests/greenio_test.py index 3ca97de..8a654a7 100644 --- a/tests/greenio_test.py +++ b/tests/greenio_test.py @@ -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 diff --git a/tests/greenpipe_test_with_statement.py b/tests/greenpipe_test_with_statement.py new file mode 100644 index 0000000..c9d2570 --- /dev/null +++ b/tests/greenpipe_test_with_statement.py @@ -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 diff --git a/tests/nosewrapper.py b/tests/nosewrapper.py index 250a020..7ac3fe0 100644 --- a/tests/nosewrapper.py +++ b/tests/nosewrapper.py @@ -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