diff options
Diffstat (limited to 'tests/test_pycode.py')
-rw-r--r-- | tests/test_pycode.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/test_pycode.py b/tests/test_pycode.py index b4385e8a6..2eab456bc 100644 --- a/tests/test_pycode.py +++ b/tests/test_pycode.py @@ -10,6 +10,7 @@ """ import os +import sys from six import PY2 @@ -47,6 +48,31 @@ def test_ModuleAnalyzer_for_module(): assert analyzer.encoding == 'utf-8' +def test_ModuleAnalyzer_for_file_in_egg(rootdir): + try: + path = rootdir / 'test-pycode-egg' / 'sample-0.0.0-py3.7.egg' + sys.path.insert(0, path) + + import sample + analyzer = ModuleAnalyzer.for_file(sample.__file__, 'sample') + docs = analyzer.find_attr_docs() + assert docs == {('', 'CONSTANT'): ['constant on sample.py', '']} + finally: + sys.path.pop(0) + + +def test_ModuleAnalyzer_for_module_in_egg(rootdir): + try: + path = rootdir / 'test-pycode-egg' / 'sample-0.0.0-py3.7.egg' + sys.path.insert(0, path) + + analyzer = ModuleAnalyzer.for_module('sample') + docs = analyzer.find_attr_docs() + assert docs == {('', 'CONSTANT'): ['constant on sample.py', '']} + finally: + sys.path.pop(0) + + def test_ModuleAnalyzer_find_tags(): code = ('class Foo(object):\n' # line: 1 ' """class Foo!"""\n' |