Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pyrasite
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
pyrasite
Commits
0ccacedf
Commit
0ccacedf
authored
Mar 28, 2012
by
Luke Macken
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #29 from ralphbean/feature/context-manager
Context manager unit test fixes
parents
d598fe14
e71ad5cf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
11 deletions
+21
-11
pyrasite/tests/context_manager_case.py
pyrasite/tests/context_manager_case.py
+16
-0
pyrasite/tests/test_ipc.py
pyrasite/tests/test_ipc.py
+5
-11
No files found.
pyrasite/tests/context_manager_case.py
0 → 100644
View file @
0ccacedf
""" 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
)
pyrasite/tests/test_ipc.py
View file @
0ccacedf
...
...
@@ -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
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment