Commits

Daniel Holth committed f5d5e4a

skip markerlib tests on Python < 2.6 (no ast compilation)

Comments (0)

Files changed (2)

setuptools/tests/test_dist_info.py

 import textwrap
 
 try:
-    import _markerlib
+    import ast
 except:
     pass
 
         assert versioned.version == '2.718' # from filename
         assert unversioned.version == '0.3' # from METADATA
 
-    @skipIf('_markerlib' not in globals(),
-        "_markerlib is used to test conditional dependencies (Python >= 2.5)")
+    @skipIf('ast' not in globals(),
+        "ast is used to test conditional dependencies (Python >= 2.6)")
     def test_conditional_dependencies(self):
         requires = [pkg_resources.Requirement.parse('splort==4'),
                     pkg_resources.Requirement.parse('quux>=1.1')]

setuptools/tests/test_markerlib.py

 from setuptools.tests.py26compat import skipIf
 
 try:
-    import _ast
+    import ast
 except ImportError:
     pass
 
 class TestMarkerlib(unittest.TestCase):
 
-    @skipIf('_ast' not in globals(),
-        "ast not available (Python < 2.5?)")
+    @skipIf('ast' not in globals(),
+        "ast not available (Python < 2.6?)")
     def test_markers(self):
         from _markerlib import interpret, default_environment, compile
         
         statement = "python_version == '5'"
         self.assertEqual(compile(statement).__doc__, statement)
         
-    @skipIf('_ast' not in globals(),
-        "ast not available (Python < 2.5?)")
-    def test_ast(self):
-        try:
-            import ast, nose
-            raise nose.SkipTest()
-        except ImportError:
-            pass
-        
-        # Nonsensical code coverage tests.
-        import _markerlib._markers_ast as _markers_ast
-        
-        class Node(_ast.AST):
-            _fields = ('bogus')
-        list(_markers_ast.iter_fields(Node()))
-        
-        class Node2(_ast.AST):
-            def __init__(self):
-                self._fields = ('bogus',)
-                self.bogus = [Node()]
-                
-        class NoneTransformer(_markers_ast.NodeTransformer):
-            def visit_Attribute(self, node):
-                return None
-            
-            def visit_Str(self, node):
-                return None
-            
-            def visit_Node(self, node):
-                return []
-                
-        NoneTransformer().visit(_markers_ast.parse('a.b = "c"'))
-        NoneTransformer().visit(Node2())
-