Skip to content

Commit 0036e2a

Browse files
committed
Fix compatibility with Python 2
1 parent 0eb42e4 commit 0036e2a

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

pytest_arraydiff/plugin.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,32 +37,42 @@
3737
import tempfile
3838
import warnings
3939

40-
from six import add_metaclass
40+
from six import add_metaclass, PY2
4141
from six.moves.urllib.request import urlopen
4242

4343
import pytest
4444
import numpy as np
4545

4646

47+
if PY2:
48+
def abstractstaticmethod(func):
49+
return func
50+
def abstractclassmethod(func):
51+
return func
52+
else:
53+
abstractstaticmethod = abc.abstractstaticmethod
54+
abstractclassmethod = abc.abstractclassmethod
55+
56+
4757
@add_metaclass(abc.ABCMeta)
4858
class BaseDiff(object):
4959

50-
@abc.abstractstaticmethod
60+
@abstractstaticmethod
5161
def read(filename):
5262
"""
5363
Given a filename, return a data object.
5464
"""
5565
raise NotImplementedError()
5666

57-
@abc.abstractstaticmethod
67+
@abstractstaticmethod
5868
def write(filename, data, **kwargs):
5969
"""
6070
Given a filename and a data object (and optional keyword arguments),
6171
write the data to a file.
6272
"""
6373
raise NotImplementedError()
6474

65-
@abc.abstractclassmethod
75+
@abstractclassmethod
6676
def compare(self, reference_file, test_file, atol=None, rtol=None):
6777
"""
6878
Given a reference and test filename, compare the data to the specified

0 commit comments

Comments
 (0)