diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-09-06 21:30:56 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-09-06 22:22:01 +0900 |
commit | 35e1764025447b8e863a68c65a666836b5099a9d (patch) | |
tree | b4c06dd45760235a0049cb7bf90c1847175576d8 /tests/test_pycode.py | |
parent | 4abc55239a5ecd52c249bf0ede0fea44504b1fc8 (diff) | |
download | sphinx-git-35e1764025447b8e863a68c65a666836b5099a9d.tar.gz |
Fix #5290: autodoc: failed to analyze source code in egg package
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' |