From 60e26e3feadfb9bec9ceb6544817f773b32f6778 Mon Sep 17 00:00:00 2001 From: Seth Hill Date: Tue, 22 Mar 2016 12:37:27 -0700 Subject: [PATCH] Fix python2 test failures --- jsonrpc/tests/p3_test_code.py | 6 ++++++ jsonrpc/tests/test_pep3107.py | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 jsonrpc/tests/p3_test_code.py diff --git a/jsonrpc/tests/p3_test_code.py b/jsonrpc/tests/p3_test_code.py new file mode 100644 index 0000000..746acad --- /dev/null +++ b/jsonrpc/tests/p3_test_code.py @@ -0,0 +1,6 @@ +# Python3-only code +# This won't even parse in python2, so it's kept in a separate file and imported +# when needed. + +def distance(a: float, b: float) -> float: + return (a**2 + b**2)**0.5 diff --git a/jsonrpc/tests/test_pep3107.py b/jsonrpc/tests/test_pep3107.py index 7f9cb6b..89cecab 100644 --- a/jsonrpc/tests/test_pep3107.py +++ b/jsonrpc/tests/test_pep3107.py @@ -1,14 +1,17 @@ import unittest +import sys from manager import JSONRPCResponseManager +if sys.version_info[0] < 3: + sys.exit(0) + +from p3_test_code import distance 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,