Skip to content

Commit

Permalink
Restore compatibility with Python 3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
lelit committed Dec 20, 2017
1 parent 7bc508a commit 94d9a0b
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions tests/test_circular.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,23 @@
# :Copyright: © 2017 Lele Gaifax
#

import sys

import pytest


if sys.version_info >= (3, 5):
expected_exception = RecursionError
else:
expected_exception = RuntimeError


@pytest.mark.unit
def test_circular_dict(dumps):
dct = {}
dct['a'] = dct

with pytest.raises(RecursionError):
with pytest.raises(expected_exception):
dumps(dct)


Expand All @@ -24,7 +31,7 @@ def test_circular_list(dumps):
lst = []
lst.append(lst)

with pytest.raises(RecursionError):
with pytest.raises(expected_exception):
dumps(lst)


Expand All @@ -34,7 +41,7 @@ def test_circular_composite(dumps):
dct2['a'] = []
dct2['a'].append(dct2)

with pytest.raises(RecursionError):
with pytest.raises(expected_exception):
dumps(dct2)

@pytest.mark.unit
Expand All @@ -52,7 +59,7 @@ def test_max_recursion_depth(dumps):
rl = sys.getrecursionlimit()
sys.setrecursionlimit(500)
try:
with pytest.raises(RecursionError):
with pytest.raises(expected_exception):
dumps(root)
finally:
sys.setrecursionlimit(rl)

0 comments on commit 94d9a0b

Please sign in to comment.