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 18
18
from datetime import timedelta
19
19
from hashlib import md5
20
20
21
+ try :
22
+ from json import JSONDecodeError
23
+ except ImportError :
24
+ JSONDecodeError = ValueError
25
+
21
26
try :
22
27
from urllib .parse import urlparse
23
28
except ImportError :
@@ -2747,7 +2752,7 @@ def raise_error_on_constant(x):
2747
2752
parse_constant = raise_error_on_constant )
2748
2753
self .value = [self .FsValue (index , self .json_dict [index ])
2749
2754
for index in self .json_dict ]
2750
- except (json . decoder . JSONDecodeError , ValueError ) as e :
2755
+ except (JSONDecodeError , ValueError ) as e :
2751
2756
raise ValueError (e .args [0 ] + ". JSON is: " + json_string )
2752
2757
2753
2758
Original file line number Diff line number Diff line change 1
1
import pytest
2
2
import unittest
3
3
import shutil
4
+ import sys
4
5
import errno
5
6
6
7
from time import sleep
@@ -63,6 +64,13 @@ def dst(self, dt):
63
64
skip_jwt = mark_class (pytest .mark .skip (
64
65
reason = 'Skipping JWT tests: jwt library not available' ))
65
66
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
+
66
74
NEEDS_INSTANCE = 1
67
75
68
76
@@ -2427,6 +2435,7 @@ def testDispatchBadAccept(self):
2427
2435
json_dict = json .loads (b2s (results ))
2428
2436
self .assertIn ('Unable to parse Accept Header. Invalid param: foo. Acceptable types: */*, application/json' , json_dict ['error' ]['msg' ])
2429
2437
2438
+ @skip_on_py2
2430
2439
def testBadJson (self ):
2431
2440
'''Run some JSON we don't accept through the wringer
2432
2441
'''
@@ -2509,7 +2518,6 @@ def testBadJson(self):
2509
2518
2510
2519
self .assertEqual (json .loads (results ), expected )
2511
2520
2512
-
2513
2521
def testStatsGen (self ):
2514
2522
# check stats being returned by put and get ops
2515
2523
# using dispatch which parses the @stats query param
You can’t perform that action at this time.
0 commit comments