Commit 25d00ab6 authored by Daniel Holth's avatar Daniel Holth

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

--HG--
branch : distribute
extra : rebase_source : 2044b531becb5ca6882bfb3b59ab53aac2c8ae2e
parent 165f9521
...@@ -7,7 +7,7 @@ import unittest ...@@ -7,7 +7,7 @@ import unittest
import textwrap import textwrap
try: try:
import _markerlib import ast
except: except:
pass pass
...@@ -34,8 +34,8 @@ class TestDistInfo(unittest.TestCase): ...@@ -34,8 +34,8 @@ class TestDistInfo(unittest.TestCase):
assert versioned.version == '2.718' # from filename assert versioned.version == '2.718' # from filename
assert unversioned.version == '0.3' # from METADATA assert unversioned.version == '0.3' # from METADATA
@skipIf('_markerlib' not in globals(), @skipIf('ast' not in globals(),
"_markerlib is used to test conditional dependencies (Python >= 2.5)") "ast is used to test conditional dependencies (Python >= 2.6)")
def test_conditional_dependencies(self): def test_conditional_dependencies(self):
requires = [pkg_resources.Requirement.parse('splort==4'), requires = [pkg_resources.Requirement.parse('splort==4'),
pkg_resources.Requirement.parse('quux>=1.1')] pkg_resources.Requirement.parse('quux>=1.1')]
......
...@@ -3,14 +3,14 @@ import unittest ...@@ -3,14 +3,14 @@ import unittest
from setuptools.tests.py26compat import skipIf from setuptools.tests.py26compat import skipIf
try: try:
import _ast import ast
except ImportError: except ImportError:
pass pass
class TestMarkerlib(unittest.TestCase): class TestMarkerlib(unittest.TestCase):
@skipIf('_ast' not in globals(), @skipIf('ast' not in globals(),
"ast not available (Python < 2.5?)") "ast not available (Python < 2.6?)")
def test_markers(self): def test_markers(self):
from _markerlib import interpret, default_environment, compile from _markerlib import interpret, default_environment, compile
...@@ -62,37 +62,3 @@ class TestMarkerlib(unittest.TestCase): ...@@ -62,37 +62,3 @@ class TestMarkerlib(unittest.TestCase):
statement = "python_version == '5'" statement = "python_version == '5'"
self.assertEqual(compile(statement).__doc__, statement) 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())
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment