summaryrefslogtreecommitdiff
path: root/tests/test_pycode.py
diff options
context:
space:
mode:
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')