Commit 0ccacedf authored by Luke Macken's avatar Luke Macken

Merge pull request #29 from ralphbean/feature/context-manager

Context manager unit test fixes
parents d598fe14 e71ad5cf
""" This is kept in a separate file so that python2.4 never picks it up. """
import pyrasite
def context_manager_business(case):
# Check that the context manager injects ipc correctly.
with pyrasite.PyrasiteIPC(case.p.pid) as ipc:
assert ipc.cmd('print("mu")') == 'mu\n'
# Check that the context manager closes the ipc correctly.
try:
ipc.cmd('print("mu")')
assert False, "The connection was not closed."
except IOError as e:
assert "Bad file descriptor" in str(e)
......@@ -33,7 +33,6 @@ class TestIPCContextManager(unittest.TestCase):
stop_program(self.p)
def test_context_manager(self):
# Check that we're on a version of python that
# supports context managers
info = sys.version_info
......@@ -41,16 +40,11 @@ class TestIPCContextManager(unittest.TestCase):
if major <= 2 and minor <= 5:
self.skipTest("Context Managers not supported on Python<=2.5")
# Check that the context manager injects ipc correctly.
with pyrasite.PyrasiteIPC(self.p.pid) as ipc:
assert ipc.cmd('print("mu")') == 'mu\n'
# Check that the context manager closes the ipc correctly.
try:
ipc.cmd('print("mu")')
assert False, "The connection was not closed."
except IOError as e:
assert "Bad file descriptor" in str(e)
# Otherwise import a module which contains modern syntax.
# It really contains our test case, but we have pushed it out into
# another module so that python 2.4 never sees it.
import context_manager_case
context_manager_case.context_manager_business(self)
class TestIPC(unittest.TestCase):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment