mirror of
				https://github.com/sphinx-doc/sphinx.git
				synced 2025-02-25 18:55:22 -06:00 
			
		
		
		
	Old get_module_source API restored, new version moved to ModuleAnalyzer class, tests updated
This commit is contained in:
		@@ -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')
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user