File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 1818from datetime import timedelta
1919from hashlib import md5
2020
21+ try :
22+ from json import JSONDecodeError
23+ except ImportError :
24+ JSONDecodeError = ValueError
25+
2126try :
2227 from urllib .parse import urlparse
2328except ImportError :
@@ -2747,7 +2752,7 @@ def raise_error_on_constant(x):
27472752 parse_constant = raise_error_on_constant )
27482753 self .value = [self .FsValue (index , self .json_dict [index ])
27492754 for index in self .json_dict ]
2750- except (json . decoder . JSONDecodeError , ValueError ) as e :
2755+ except (JSONDecodeError , ValueError ) as e :
27512756 raise ValueError (e .args [0 ] + ". JSON is: " + json_string )
27522757
27532758
Original file line number Diff line number Diff line change 11import pytest
22import unittest
33import shutil
4+ import sys
45import errno
56
67from time import sleep
@@ -63,6 +64,13 @@ def dst(self, dt):
6364 skip_jwt = mark_class (pytest .mark .skip (
6465 reason = 'Skipping JWT tests: jwt library not available' ))
6566
67+ if sys .version_info [0 ] > 2 :
68+ skip_on_py2 = lambda func , * args , ** kwargs : func
69+ else :
70+ from .pytest_patcher import mark_class
71+ skip_on_py2 = mark_class (pytest .mark .skip (
72+ reason = 'Skipping test on Python 2' ))
73+
6674NEEDS_INSTANCE = 1
6775
6876
@@ -2427,6 +2435,7 @@ def testDispatchBadAccept(self):
24272435 json_dict = json .loads (b2s (results ))
24282436 self .assertIn ('Unable to parse Accept Header. Invalid param: foo. Acceptable types: */*, application/json' , json_dict ['error' ]['msg' ])
24292437
2438+ @skip_on_py2
24302439 def testBadJson (self ):
24312440 '''Run some JSON we don't accept through the wringer
24322441 '''
@@ -2509,7 +2518,6 @@ def testBadJson(self):
25092518
25102519 self .assertEqual (json .loads (results ), expected )
25112520
2512-
25132521 def testStatsGen (self ):
25142522 # check stats being returned by put and get ops
25152523 # using dispatch which parses the @stats query param
You can’t perform that action at this time.
0 commit comments