Viewcode: Fix issue with import paths that differ from the directory structure (#13195)

Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
This commit is contained in:
ProGamerGov
2025-01-05 03:43:57 -07:00
committed by GitHub
parent 83bf866059
commit fec4d7c2f1
10 changed files with 119 additions and 6 deletions

View File

@@ -162,3 +162,24 @@ def test_local_source_files(app):
'This is the class attribute class_attr',
):
assert result.count(needle) == 1
@pytest.mark.sphinx('html', testroot='ext-viewcode-find-package', freshenv=True)
def test_find_local_package_import_path(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'index.html').read_text(encoding='utf8')
count_func1 = result.count(
'href="_modules/main_package/subpackage/_subpackage2/submodule.html#func1"'
)
assert count_func1 == 1
count_class1 = result.count(
'href="_modules/main_package/subpackage/_subpackage2/submodule.html#Class1"'
)
assert count_class1 == 1
count_class3 = result.count(
'href="_modules/main_package/subpackage/_subpackage2/submodule.html#Class3"'
)
assert count_class3 == 1