-
-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Occurs when jsonrpc method has PEP3107 annotations, and is called with incorrect parameters.
- Loading branch information
Showing
2 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import unittest | ||
from manager import JSONRPCResponseManager | ||
|
||
|
||
class TestJSONRPCResponseManager(unittest.TestCase): | ||
def test_typeerror_with_annotations(self): | ||
"""If a function has Python3 annotations and is called with improper | ||
arguments, make sure the framework doesn't fail with inspect.getargspec | ||
""" | ||
def distance(a: float, b: float) -> float: | ||
return (a**2 + b**2)**0.5 | ||
|
||
dispatcher = { | ||
"distance": distance, | ||
} | ||
|
||
req = '{"jsonrpc": "2.0", "method": "distance", "params": [], "id": 3}' # noqa | ||
result = JSONRPCResponseManager.handle(req, dispatcher) | ||
|
||
# Make sure this returns JSONRPCInvalidParams rather than raising | ||
# UnboundLocalError | ||
self.assertEqual(result.error['code'], -32602) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters