/usr/lib/python2.7/dist-packages/traits/util/tests/test_trait_documenter.py is in python-traits 4.6.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | """ Tests for the trait documenter. """
import StringIO
import sys
import tokenize
from traits.testing.unittest_tools import unittest
def _sphinx_present():
try:
import sphinx # noqa
except ImportError:
return False
return True
def _python_version_is_32():
return sys.version_info[:2] == (3, 2)
# Skipping for python 3.2 because sphinx does not work on it.
@unittest.skipIf(not _sphinx_present() or _python_version_is_32(),
"Sphinx not available. Cannot test documenter")
class TestTraitDocumenter(unittest.TestCase):
""" Tests for the trait documenter. """
def setUp(self):
self.source = """
depth_interval = Property(Tuple(Float, Float),
depends_on="_depth_interval")
"""
string_io = StringIO.StringIO(self.source)
tokens = tokenize.generate_tokens(string_io.readline)
self.tokens = tokens
def test_get_definition_tokens(self):
from traits.util.trait_documenter import _get_definition_tokens
definition_tokens = _get_definition_tokens(self.tokens)
# Check if they are correctly untokenized. This should not raise.
string = tokenize.untokenize(definition_tokens)
self.assertEqual(self.source.rstrip(), string)
if __name__ == '__main__':
unittest.main()
# ## EOF ######################################################################
|