Commit 86368a5e authored by Ralph Bean's avatar Ralph Bean

Broke context manager test out into it's own file.

parent cdca3dfc
import sys
import unittest
import pyrasite
from pyrasite.tests.utils import run_program, generate_program, stop_program
class TestIPCContextManager(unittest.TestCase):
def setUp(self):
self.prog = generate_program()
self.p = run_program(self.prog)
def tearDown(self):
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
major, minor = info[0], info[1]
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)
......@@ -16,43 +16,12 @@
# Copyright (C) 2011, 2012 Red Hat, Inc.
import os
import sys
import unittest
import pyrasite
from pyrasite.tests.utils import run_program, generate_program, stop_program
class TestIPCContextManager(unittest.TestCase):
def setUp(self):
self.prog = generate_program()
self.p = run_program(self.prog)
def tearDown(self):
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
major, minor = info[0], info[1]
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)
class TestIPC(unittest.TestCase):
def setUp(self):
......
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