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
86368a5e
Commit
86368a5e
authored
Mar 28, 2012
by
Ralph Bean
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Broke context manager test out into it's own file.
parent
cdca3dfc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
31 deletions
+35
-31
pyrasite/tests/test_context_manager.py
pyrasite/tests/test_context_manager.py
+35
-0
pyrasite/tests/test_ipc.py
pyrasite/tests/test_ipc.py
+0
-31
No files found.
pyrasite/tests/test_context_manager.py
0 → 100644
View file @
86368a5e
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
)
pyrasite/tests/test_ipc.py
View file @
86368a5e
...
...
@@ -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
):
...
...
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