From 22a084d3011a6848fe8ae96fdce591cd75c7b037 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Wed, 25 Jul 2018 23:53:25 +0800 Subject: [PATCH] bugfix: JSONDecodeError in Python3.4 --- httprunner/compat.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/httprunner/compat.py b/httprunner/compat.py index e58ea033..ae88f4c9 100644 --- a/httprunner/compat.py +++ b/httprunner/compat.py @@ -8,7 +8,11 @@ This module handles import compatibility issues between Python 2 and Python 3. """ -import json +try: + import simplejson as json +except ImportError: + import json + import sys # ------- @@ -29,6 +33,11 @@ is_py3 = (_ver[0] == 3) # Specifics # --------- +try: + JSONDecodeError = json.JSONDecodeError +except AttributeError: + JSONDecodeError = ValueError + if is_py2: from urllib3.packages.ordered_dict import OrderedDict @@ -40,7 +49,6 @@ if is_py2: integer_types = (int, long) FileNotFoundError = IOError - JSONDecodeError = ValueError elif is_py3: from collections import OrderedDict @@ -53,4 +61,3 @@ elif is_py3: integer_types = (int,) FileNotFoundError = FileNotFoundError - JSONDecodeError = json.decoder.JSONDecodeError