Skip to content

Commit 8b2baaa

Browse files
author
Sylvain MARIE
committed
Fixed tests on python 2
1 parent 33dd56d commit 8b2baaa

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

pyfields/tests/issues/test_issue_84.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1-
from abc import ABC
1+
import sys
22

33
import pytest
44

5+
try:
6+
from abc import ABC
7+
except ImportError:
8+
from abc import ABCMeta
9+
10+
class ABC:
11+
__metaclass__ = ABCMeta
12+
13+
514
from pyfields import autofields, field, copy_value, autoclass
615

716

17+
@pytest.mark.skipif(sys.version_info < (3,), reason="This test does not yet reproduce the exception in python 2")
818
@pytest.mark.parametrize("auto,deep", [(False, False), (False, True), (True, None)])
919
def test_issue_deepcopy_autofields(auto, deep):
1020
"""Make sure that """
@@ -45,6 +55,10 @@ class Foo(ABC):
4555
g = Foo()
4656
assert g.a == 0
4757

58+
if sys.version_info < (3,):
59+
# errors below wont be raised anyway
60+
return
61+
4862
with pytest.raises(ValueError) as exc_info:
4963
@autofields(exclude=())
5064
class Foo(ABC):
@@ -63,6 +77,10 @@ class Foo(ABC):
6377
f = Foo()
6478
assert str(f) == "Foo(a=0)"
6579

80+
if sys.version_info < (3,):
81+
# errors below wont be raised anyway
82+
return
83+
6684
with pytest.raises(ValueError) as exc_info:
6785
@autoclass(af_exclude=())
6886
class Foo(ABC):

0 commit comments

Comments
 (0)