This repository has been archived on 2025-02-01. You can view files and clone it, but cannot push or open issues or pull requests.
PyBitmessage-2025-02-01/mockenv/lib/python3.6/site-packages/jsonrpc/tests/test_pep3107.py
2022-07-22 16:13:59 +05:30

29 lines
907 B
Python

from ..manager import JSONRPCResponseManager
import sys
if sys.version_info < (2, 7):
import unittest2 as unittest
else:
import unittest
class TestJSONRPCResponseManager(unittest.TestCase):
@unittest.skipIf(sys.version_info < (3, 5), "Test Py3.5+ functionality")
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
"""
from .py35_utils import distance
dispatcher = {
"distance": distance,
}
req = '{"jsonrpc": "2.0", "method": "distance", "params": [], "id": 1}'
result = JSONRPCResponseManager.handle(req, dispatcher)
# Make sure this returns JSONRPCInvalidParams rather than raising
# UnboundLocalError
self.assertEqual(result.error['code'], -32602)