Skip to content

Commit

Permalink
Module level pytest skip is not available in pytest for 3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
dflook committed Aug 18, 2024
1 parent 0e961df commit 705829d
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 6 deletions.
60 changes: 58 additions & 2 deletions test/test_bind_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ def namespace_name(node):
return s

def test_module_namespace():
if sys.version_info < (3, 0):
pytest.skip('Test requires python 3.0 or later')

source = '''
name_in_module = True
name_in_module = True
Expand All @@ -67,6 +70,9 @@ def test_module_namespace():


def test_lambda_namespace():
if sys.version_info < (3, 0):
pytest.skip('Test requires python 3.0 or later')

source = '''
name_in_module = True
Expand All @@ -86,6 +92,9 @@ def test_lambda_namespace():
assert_namespace_tree(source, expected_namespaces)

def test_function_namespace():
if sys.version_info < (3, 0):
pytest.skip('Test requires python 3.0 or later')

source = '''
name_in_module = True
Expand Down Expand Up @@ -151,6 +160,9 @@ async def inner_func():
# region generator namespace

def test_generator_namespace():
if sys.version_info < (3, 0):
pytest.skip('Test requires python 3.0 or later')

source = '''
a = (x for x in range(10))
'''
Expand All @@ -166,6 +178,9 @@ def test_generator_namespace():
assert_namespace_tree(source, expected_namespaces)

def test_multi_generator_namespace():
if sys.version_info < (3, 0):
pytest.skip('Test requires python 3.0 or later')

source = '''
x = []
f = []
Expand All @@ -184,6 +199,9 @@ def test_multi_generator_namespace():
assert_namespace_tree(source, expected_namespaces)

def test_multi_generator_namespace_2():
if sys.version_info < (3, 0):
pytest.skip('Test requires python 3.0 or later')

source = '''
c = ''
line = ''
Expand All @@ -205,6 +223,9 @@ def test_multi_generator_namespace_2():
assert_namespace_tree(source, expected_namespaces)

def test_nested_generator():
if sys.version_info < (3, 0):
pytest.skip('Test requires python 3.0 or later')

source = '''
c = ''
line = ''
Expand All @@ -227,6 +248,9 @@ def test_nested_generator():
assert_namespace_tree(source, expected_namespaces)

def test_nested_generator_2():
if sys.version_info < (3, 0):
pytest.skip('Test requires python 3.0 or later')

source = '''
x = ''
a = (x for x in (x for x in x))
Expand All @@ -250,6 +274,9 @@ def test_nested_generator_2():
# region setcomp

def test_setcomp_namespace():
if sys.version_info < (3, 0):
pytest.skip('Test requires python 3.0 or later')

source = '''
a = {x for x in range(10)}
'''
Expand All @@ -265,6 +292,9 @@ def test_setcomp_namespace():
assert_namespace_tree(source, expected_namespaces)

def test_multi_setcomp_namespace():
if sys.version_info < (3, 0):
pytest.skip('Test requires python 3.0 or later')

source = '''
x = []
f = []
Expand All @@ -283,6 +313,9 @@ def test_multi_setcomp_namespace():
assert_namespace_tree(source, expected_namespaces)

def test_multi_setcomp_namespace_2():
if sys.version_info < (3, 0):
pytest.skip('Test requires python 3.0 or later')

source = '''
c = ''
line = ''
Expand All @@ -304,6 +337,9 @@ def test_multi_setcomp_namespace_2():
assert_namespace_tree(source, expected_namespaces)

def test_nested_setcomp():
if sys.version_info < (3, 0):
pytest.skip('Test requires python 3.0 or later')

source = '''
c = ''
line = ''
Expand All @@ -326,6 +362,9 @@ def test_nested_setcomp():
assert_namespace_tree(source, expected_namespaces)

def test_nested_setcomp_2():
if sys.version_info < (3, 0):
pytest.skip('Test requires python 3.0 or later')

source = '''
x = ''
a = {x for x in {x for x in x}}
Expand Down Expand Up @@ -461,6 +500,9 @@ def test_nested_listcomp_2():
# region dictcomp

def test_dictcomp_namespace():
if sys.version_info < (3, 0):
pytest.skip('Test requires python 3.0 or later')

source = '''
a = {x: x for x in range(10)}
'''
Expand All @@ -476,6 +518,9 @@ def test_dictcomp_namespace():
assert_namespace_tree(source, expected_namespaces)

def test_multi_dictcomp_namespace():
if sys.version_info < (3, 0):
pytest.skip('Test requires python 3.0 or later')

source = '''
x = []
f = []
Expand All @@ -494,6 +539,9 @@ def test_multi_dictcomp_namespace():
assert_namespace_tree(source, expected_namespaces)

def test_multi_dictcomp_namespace_2():
if sys.version_info < (3, 0):
pytest.skip('Test requires python 3.0 or later')

source = '''
c = ''
line = ''
Expand All @@ -515,6 +563,9 @@ def test_multi_dictcomp_namespace_2():
assert_namespace_tree(source, expected_namespaces)

def test_nested_dictcomp():
if sys.version_info < (3, 0):
pytest.skip('Test requires python 3.0 or later')

source = '''
c = ''
line = ''
Expand All @@ -537,6 +588,9 @@ def test_nested_dictcomp():
assert_namespace_tree(source, expected_namespaces)

def test_nested_dictcomp_2():
if sys.version_info < (3, 0):
pytest.skip('Test requires python 3.0 or later')

source = '''
x = {}
a = {x:x for x, x in {x: x for x in x}}
Expand All @@ -557,6 +611,8 @@ def test_nested_dictcomp_2():
# endregion

def test_class_namespace():
if sys.version_info < (3, 6):
pytest.skip('Annotations are not available in python < 3.6')

source = '''
OhALongName = 'Hello'
Expand Down Expand Up @@ -591,6 +647,8 @@ class C:


def test_class_name_rebinding():
if sys.version_info < (3, 0):
pytest.skip('Test requires python 3.0 or later')

source = '''
OhALongName = 'Hello'
Expand Down Expand Up @@ -620,5 +678,3 @@ class C:

assert_namespace_tree(source, expected_namespaces)

if sys.version_info < (3, 0):
pytest.skip(allow_module_level=True)
Loading

0 comments on commit 705829d

Please sign in to comment.