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 66 :copyright: (c) by Vital Kudzelka
77 :license: MIT
88"""
9+ import sys
10+
911import pytest
1012
1113from flask import json
@@ -32,7 +34,17 @@ def json(self):
3234 def __eq__ (self , other ):
3335 if isinstance (other , int ):
3436 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 )
3648
3749 def __ne__ (self , other ):
3850 return not self == other
You can’t perform that action at this time.
0 commit comments