-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #251 from enthought/fix/250-trait-documenter-fails…
…-multiline Fix for issue 250: Trait documenter failure for multiline traits.
- Loading branch information
Showing
2 changed files
with
90 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 ###################################################################### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters