File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 6
6
:copyright: (c) by Vital Kudzelka
7
7
:license: MIT
8
8
"""
9
+ import sys
10
+
9
11
import pytest
10
12
11
13
from flask import json
@@ -32,7 +34,17 @@ def json(self):
32
34
def __eq__ (self , other ):
33
35
if isinstance (other , int ):
34
36
return self .status_code == other
35
- return super (JSONResponse , self ).__eq__ (other )
37
+ # even though the Python 2-specific code works on Python 3, keep the two versions
38
+ # separate so we can simplify the code once Python 2 support is dropped
39
+ if sys .version_info [0 ] == 2 :
40
+ try :
41
+ super_eq = super (JSONResponse , self ).__eq__
42
+ except AttributeError :
43
+ return NotImplemented
44
+ else :
45
+ return super_eq (other )
46
+ else :
47
+ return super (JSONResponse , self ).__eq__ (other )
36
48
37
49
def __ne__ (self , other ):
38
50
return not self == other
You can’t perform that action at this time.
0 commit comments