Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mitogen
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
mitogen
Commits
118fe01b
Commit
118fe01b
authored
Sep 30, 2017
by
David Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use enhanced assertRaises in call_function_test.py.
parent
9b13a4cc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
15 deletions
+11
-15
tests/call_function_test.py
tests/call_function_test.py
+11
-15
No files found.
tests/call_function_test.py
View file @
118fe01b
import
logging
import
unittest
import
mitogen.core
import
mitogen.master
import
testlib
class
CrazyType
(
object
):
pass
...
...
@@ -28,7 +31,7 @@ def func_accepts_returns_context(context):
return
context
class
CallFunctionTest
(
testlib
.
RouterMixin
,
unittest
.
TestCase
):
class
CallFunctionTest
(
testlib
.
RouterMixin
,
testlib
.
TestCase
):
def
setUp
(
self
):
super
(
CallFunctionTest
,
self
).
setUp
()
self
.
local
=
self
.
router
.
local
()
...
...
@@ -37,13 +40,10 @@ class CallFunctionTest(testlib.RouterMixin, unittest.TestCase):
assert
3
==
self
.
local
.
call
(
function_that_adds_numbers
,
1
,
2
)
def
test_crashes
(
self
):
try
:
self
.
local
.
call
(
function_that_fails
)
assert
0
,
'call didnt fail'
except
mitogen
.
core
.
CallError
,
e
:
pass
exc
=
self
.
assertRaises
(
mitogen
.
core
.
CallError
,
lambda
:
self
.
local
.
call
(
function_that_fails
))
s
=
str
(
e
)
s
=
str
(
e
xc
)
etype
,
_
,
s
=
s
.
partition
(
': '
)
assert
etype
==
'exceptions.ValueError'
...
...
@@ -54,13 +54,9 @@ class CallFunctionTest(testlib.RouterMixin, unittest.TestCase):
assert
len
(
s
)
>
0
def
test_bad_return_value
(
self
):
try
:
self
.
local
.
call
(
func_with_bad_return_value
)
assert
0
,
'call didnt fail'
except
mitogen
.
core
.
StreamError
,
e
:
pass
self
.
assertEquals
(
e
[
0
],
"cannot unpickle '__main__'/'CrazyType'"
)
exc
=
self
.
assertRaises
(
mitogen
.
core
.
StreamError
,
lambda
:
self
.
local
.
call
(
func_with_bad_return_value
))
self
.
assertEquals
(
exc
[
0
],
"cannot unpickle '__main__'/'CrazyType'"
)
def
test_returns_dead
(
self
):
assert
mitogen
.
core
.
_DEAD
==
self
.
local
.
call
(
func_returns_dead
)
...
...
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