-
Notifications
You must be signed in to change notification settings - Fork 3
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 #10 from enthought/fix-issue-9
update implementation to use the astor library
- Loading branch information
Showing
10 changed files
with
110 additions
and
17 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
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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
coverage | ||
mock | ||
unittest2 | ||
unittest2 ; python_version < '2.7' | ||
haas |
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
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
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
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,46 @@ | ||
from __future__ import unicode_literals | ||
import unittest | ||
|
||
import mock | ||
|
||
from trait_documenter.module_trait_documenter import ( | ||
ModuleTraitDocumenter) | ||
from trait_documenter.tests import test_file | ||
from trait_documenter.tests.test_file import Dummy | ||
|
||
|
||
class TestModuleTraitDocumenter(unittest.TestCase): | ||
|
||
def test_can_document_member(self): | ||
can_document_member = ModuleTraitDocumenter.can_document_member | ||
parent = mock.Mock() | ||
|
||
# modules | ||
parent.object = test_file | ||
self.assertFalse(can_document_member(Dummy, 'Dummy', False, parent)) | ||
self.assertFalse(can_document_member( | ||
test_file.module_trait, 'module_trait', False, parent)) | ||
self.assertTrue(can_document_member( | ||
test_file.module_trait, 'module_trait', True, parent)) | ||
|
||
parent.object = Dummy | ||
self.assertFalse( | ||
can_document_member( | ||
Dummy.class_traits()['trait_1'], 'trait_1', True, parent)) | ||
self.assertFalse( | ||
can_document_member( | ||
Dummy.class_traits()['trait_1'], 'trait_1', False, parent)) | ||
self.assertFalse( | ||
can_document_member( | ||
Dummy.not_trait, 'not_trait', False, parent)) | ||
|
||
def test_module_level_trait_definition(self): | ||
documenter = ModuleTraitDocumenter(mock.Mock(), 'test') | ||
documenter.parent = test_file | ||
documenter.object_name = 'module_trait' | ||
definition = documenter.get_trait_definition() | ||
self.assertEqual(definition, "Int") | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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
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,19 @@ | ||
def is_python_26(): | ||
import sys | ||
return sys.version_info < (2, 6) | ||
|
||
|
||
class expected_failure_when(object): | ||
|
||
def __init__(self, condition): | ||
self.condition = condition | ||
|
||
def __call__(self, function): | ||
if self.condition: | ||
if is_python_26(): | ||
import unittest2 as unittest | ||
else: | ||
import unittest | ||
return unittest.expectedFailure(function) | ||
else: | ||
return function |
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