Skip to content

Commit

Permalink
fix: tests across versions
Browse files Browse the repository at this point in the history
  • Loading branch information
rubik committed Mar 25, 2023
1 parent a2359ce commit 786ac37
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 37 deletions.
78 changes: 42 additions & 36 deletions radon/tests/test_complexity_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,42 +81,6 @@
4,
{},
),
(
'''
match a:
case 1: pass
''',
2,
{},
),
(
'''
match a:
case 1: pass
case _: pass
''',
2,
{},
),
(
'''
match a:
case 1: pass
case 2: pass
''',
3,
{},
),
(
'''
match a:
case 1: pass
case 2: pass
case _: pass
''',
3,
{},
),
(
'''
for x in range(10): print(x)
Expand Down Expand Up @@ -402,9 +366,51 @@ def test_yo(self):
),
]

# The match statement was introduced in Python 3.10
MATCH_STATEMENT_BLOCKS = [
(
'''
match a:
case 1: pass
''',
2,
{},
),
(
'''
match a:
case 1: pass
case _: pass
''',
2,
{},
),
(
'''
match a:
case 1: pass
case 2: pass
''',
3,
{},
),
(
'''
match a:
case 1: pass
case 2: pass
case _: pass
''',
3,
{},
),
]

BLOCKS = SIMPLE_BLOCKS[:]
if sys.version_info[:2] >= (2, 7):
BLOCKS.extend(ADDITIONAL_BLOCKS)
if sys.version_info[:2] >= (3, 10):
BLOCKS.extend(MATCH_STATEMENT_BLOCKS)


@pytest.mark.parametrize('code,expected,kwargs', BLOCKS)
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py27,py33,py34,py35,py36,py37,py38,py39,pypy
envlist = py27,py33,py34,py35,py36,py37,py38,py39,py310,pypy

[testenv]
deps = -r{toxinidir}/test_requirements.txt
Expand Down

0 comments on commit 786ac37

Please sign in to comment.