diff --git a/test/test_bind_names.py b/test/test_bind_names.py index 3ea39a5b..9f167f6f 100644 --- a/test/test_bind_names.py +++ b/test/test_bind_names.py @@ -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 @@ -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 @@ -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 @@ -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)) ''' @@ -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 = [] @@ -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 = '' @@ -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 = '' @@ -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)) @@ -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)} ''' @@ -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 = [] @@ -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 = '' @@ -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 = '' @@ -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}} @@ -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)} ''' @@ -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 = [] @@ -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 = '' @@ -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 = '' @@ -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}} @@ -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' @@ -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' @@ -620,5 +678,3 @@ class C: assert_namespace_tree(source, expected_namespaces) -if sys.version_info < (3, 0): - pytest.skip(allow_module_level=True) \ No newline at end of file diff --git a/test/test_bind_names_python2.py b/test/test_bind_names_python2.py index 1d4b28f8..03f412d4 100644 --- a/test/test_bind_names_python2.py +++ b/test/test_bind_names_python2.py @@ -54,6 +54,9 @@ def namespace_name(node): def test_module_namespace(): + if sys.version_info >= (3, 0): + pytest.skip('Test is for python 2 only') + source = ''' name_in_module = True name_in_module = True @@ -69,6 +72,9 @@ def test_module_namespace(): def test_lambda_namespace(): + if sys.version_info >= (3, 0): + pytest.skip('Test is for python 2 only') + source = ''' name_in_module = 0 @@ -89,6 +95,9 @@ def test_lambda_namespace(): def test_function_namespace(): + if sys.version_info >= (3, 0): + pytest.skip('Test is for python 2 only') + source = ''' name_in_module = True @@ -122,6 +131,9 @@ def inner_func(): # region generator namespace def test_generator_namespace(): + if sys.version_info >= (3, 0): + pytest.skip('Test is for python 2 only') + source = ''' a = (x for x in range(10)) ''' @@ -138,6 +150,9 @@ def test_generator_namespace(): def test_multi_generator_namespace(): + if sys.version_info >= (3, 0): + pytest.skip('Test is for python 2 only') + source = ''' x = [] f = [] @@ -157,6 +172,9 @@ def test_multi_generator_namespace(): def test_multi_generator_namespace_2(): + if sys.version_info >= (3, 0): + pytest.skip('Test is for python 2 only') + source = ''' c = '' line = '' @@ -179,6 +197,9 @@ def test_multi_generator_namespace_2(): def test_nested_generator(): + if sys.version_info >= (3, 0): + pytest.skip('Test is for python 2 only') + source = ''' c = '' line = '' @@ -202,6 +223,9 @@ def test_nested_generator(): def test_nested_generator_2(): + if sys.version_info >= (3, 0): + pytest.skip('Test is for python 2 only') + source = ''' x = '' a = (x for x in (x for x in x)) @@ -226,6 +250,9 @@ def test_nested_generator_2(): # region setcomp def test_setcomp_namespace(): + if sys.version_info >= (3, 0): + pytest.skip('Test is for python 2 only') + source = ''' a = {x for x in range(10)} ''' @@ -242,6 +269,9 @@ def test_setcomp_namespace(): def test_multi_setcomp_namespace(): + if sys.version_info >= (3, 0): + pytest.skip('Test is for python 2 only') + source = ''' x = [] f = [] @@ -261,6 +291,9 @@ def test_multi_setcomp_namespace(): def test_multi_setcomp_namespace_2(): + if sys.version_info >= (3, 0): + pytest.skip('Test is for python 2 only') + source = ''' c = '' line = '' @@ -283,6 +316,9 @@ def test_multi_setcomp_namespace_2(): def test_nested_setcomp(): + if sys.version_info >= (3, 0): + pytest.skip('Test is for python 2 only') + source = ''' c = '' line = '' @@ -306,6 +342,9 @@ def test_nested_setcomp(): def test_nested_setcomp_2(): + if sys.version_info >= (3, 0): + pytest.skip('Test is for python 2 only') + source = ''' x = '' a = {x for x in {x for x in x}} @@ -329,6 +368,8 @@ def test_nested_setcomp_2(): # region listcomp def test_listcomp_namespace(): + if sys.version_info >= (3, 0): + pytest.skip('Test is for python 2 only') source = ''' a = [x for x in range(10)] @@ -345,6 +386,9 @@ def test_listcomp_namespace(): def test_multi_listcomp_namespace(): + if sys.version_info >= (3, 0): + pytest.skip('Test is for python 2 only') + source = ''' x = [] f = [] @@ -362,6 +406,9 @@ def test_multi_listcomp_namespace(): def test_multi_listcomp_namespace_2(): + if sys.version_info >= (3, 0): + pytest.skip('Test is for python 2 only') + source = ''' c = '' line = '' @@ -381,6 +428,9 @@ def test_multi_listcomp_namespace_2(): def test_nested_listcomp(): + if sys.version_info >= (3, 0): + pytest.skip('Test is for python 2 only') + source = ''' c = '' line = '' @@ -400,6 +450,9 @@ def test_nested_listcomp(): def test_nested_listcomp_2(): + if sys.version_info >= (3, 0): + pytest.skip('Test is for python 2 only') + source = ''' x = '' a =[x for x in [x for x in x]] @@ -419,6 +472,9 @@ def test_nested_listcomp_2(): # region dictcomp def test_dictcomp_namespace(): + if sys.version_info >= (3, 0): + pytest.skip('Test is for python 2 only') + source = ''' a = {x: x for x in range(10)} ''' @@ -435,6 +491,9 @@ def test_dictcomp_namespace(): def test_multi_dictcomp_namespace(): + if sys.version_info >= (3, 0): + pytest.skip('Test is for python 2 only') + source = ''' x = [] f = [] @@ -454,6 +513,9 @@ def test_multi_dictcomp_namespace(): def test_multi_dictcomp_namespace_2(): + if sys.version_info >= (3, 0): + pytest.skip('Test is for python 2 only') + source = ''' c = '' line = '' @@ -476,6 +538,9 @@ def test_multi_dictcomp_namespace_2(): def test_nested_dictcomp(): + if sys.version_info >= (3, 0): + pytest.skip('Test is for python 2 only') + source = ''' c = '' line = '' @@ -499,6 +564,9 @@ def test_nested_dictcomp(): def test_nested_dictcomp_2(): + if sys.version_info >= (3, 0): + pytest.skip('Test is for python 2 only') + source = ''' x = {} a = {x:x for x, x in {x: x for x in x}} @@ -520,6 +588,8 @@ def test_nested_dictcomp_2(): # endregion def test_class_namespace(): + if sys.version_info >= (3, 0): + pytest.skip('Test is for python 2 only') source = ''' OhALongName = 'Hello' @@ -552,6 +622,8 @@ class C: def test_class_name_rebinding(): + if sys.version_info >= (3, 0): + pytest.skip('Test is for python 2 only') source = ''' OhALongName = 'Hello' @@ -580,7 +652,3 @@ class C: ''' assert_namespace_tree(source, expected_namespaces) - - -if sys.version_info >= (3, 0): - pytest.skip(allow_module_level=True) \ No newline at end of file