Skip to content

Commit

Permalink
Added test
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanoborini committed Jul 20, 2015
1 parent ed999c4 commit b1a8b4a
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions traits/util/tests/test_trait_documenter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
""" Tests for the trait documenter. """

import tokenize

from traits.util.trait_documenter import _get_definition_tokens
from traits.testing.unittest_tools import unittest


class TestTraitDocumenter(unittest.TestCase):
""" Tests for the trait documenter. """

def setUp(self):
self.tokens = [
(1, 'Property', (12, 21), (12, 29),
' depth_interval = Property(Tuple(Float, Float),\n'),
(51, '(', (12, 29), (12, 30),
' depth_interval = Property(Tuple(Float, Float),\n'),
(1, 'Tuple', (12, 30), (12, 35),
' depth_interval = Property(Tuple(Float, Float),\n'),
(51, '(', (12, 35), (12, 36),
' depth_interval = Property(Tuple(Float, Float),\n'),
(1, 'Float', (12, 36), (12, 41),
' depth_interval = Property(Tuple(Float, Float),\n'),
(51, ',', (12, 41), (12, 42),
' depth_interval = Property(Tuple(Float, Float),\n'),
(1, 'Float', (12, 43), (12, 48),
' depth_interval = Property(Tuple(Float, Float),\n'),
(51, ')', (12, 48), (12, 49),
' depth_interval = Property(Tuple(Float, Float),\n'),
(51, ',', (12, 49), (12, 50),
' depth_interval = Property(Tuple(Float, Float),\n'),
(54, '\n', (12, 50), (12, 51),
' depth_interval = Property(Tuple(Float, Float),\n'),
(1, 'depends_on', (13, 30), (13, 40),
' depends_on="_depth_interval")\n'),
(51, '=', (13, 40), (13, 41),
' depends_on="_depth_interval")\n'),
(3, '"_depth_interval"', (13, 41), (13, 58),
' depends_on="_depth_interval")\n'),
(51, ')', (13, 58), (13, 59),
' depends_on="_depth_interval")\n'),
(4, '\n', (13, 59), (13, 60),
' depends_on="_depth_interval")\n')]

def test_get_definition_tokens(self):
definition_tokens = _get_definition_tokens(self.tokens)

# Check if they are correctly untokenized. This should not raise.
tokenize.untokenize(definition_tokens)

if __name__ == '__main__':
unittest.main()

# ## EOF ######################################################################

0 comments on commit b1a8b4a

Please sign in to comment.