summaryrefslogtreecommitdiff
path: root/tests/test_pycode.py
diff options
context:
space:
mode:
authorhkm <hkm@mail.ru>2019-12-25 22:29:20 +0300
committerhkm <hkm@mail.ru>2019-12-25 22:29:20 +0300
commit0a982d5ebd1cdb660d07e476aefa0d438e71fcb0 (patch)
treea1076f171b65c8d868a604614f792f06665fe37b /tests/test_pycode.py
parentc4e60b5b9ce786f941dd29d7636b39dd6c0d0630 (diff)
downloadsphinx-git-0a982d5ebd1cdb660d07e476aefa0d438e71fcb0.tar.gz
Old get_module_source API restored, new version moved to ModuleAnalyzer class, tests updated
Diffstat (limited to 'tests/test_pycode.py')
-rw-r--r--tests/test_pycode.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/test_pycode.py b/tests/test_pycode.py
index cd039070c..be61d9efb 100644
--- a/tests/test_pycode.py
+++ b/tests/test_pycode.py
@@ -10,12 +10,23 @@
import os
import sys
+import pytest
import sphinx
from sphinx.pycode import ModuleAnalyzer
+from sphinx.errors import PycodeError
SPHINX_MODULE_PATH = os.path.splitext(sphinx.__file__)[0] + '.py'
+def test_ModuleAnalyzer_get_module_source():
+ assert ModuleAnalyzer.get_module_source('sphinx') == (sphinx.__file__, sphinx.__loader__.get_source('sphinx'))
+
+ # failed to obtain source information from builtin modules
+ with pytest.raises(PycodeError):
+ ModuleAnalyzer.get_module_source('builtins')
+ with pytest.raises(PycodeError):
+ ModuleAnalyzer.get_module_source('itertools')
+
def test_ModuleAnalyzer_for_string():
analyzer = ModuleAnalyzer.for_string('print("Hello world")', 'module_name')