Skip to content

Commit e07fb09

Browse files
authored
Fix coverage (#194)
1 parent eeb1db1 commit e07fb09

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/scanpydoc/elegant_typehints/_role_mapping.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def __getitem__(self, key: tuple[str | None, str]) -> tuple[str | None, str]:
5555
raise KeyError(key)
5656

5757
def __contains__(self, key: object) -> bool:
58-
if not isinstance(key, tuple):
58+
if not isinstance(key, tuple): # pragma: no cover
5959
raise TypeError
6060
try:
6161
self[key]
@@ -69,5 +69,5 @@ def __delitem__(self, key: tuple[str | None, str]) -> None:
6969
def __iter__(self) -> Iterator[tuple[str | None, str]]:
7070
return self.data.__iter__()
7171

72-
def __len__(self) -> int:
72+
def __len__(self) -> int: # pragma: no cover
7373
return len(self.data)

tests/test_elegant_typehints.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def app(make_app_setup: MakeApp) -> Sphinx:
7373
"testmod.Class": "test.Class",
7474
"testmod.SubCl": "test.SubCl",
7575
"testmod.Excep": "test.Excep",
76-
"testmod.Excep2": "test.Excep2",
76+
"testmod.Excep2": ("py:exc", "test.Excep2"),
7777
"testmod.Gen": "test.Gen",
7878
},
7979
)
@@ -248,7 +248,11 @@ def fn_test(m: object) -> None: # pragma: no cover
248248
]
249249

250250

251-
def test_resolve(app: Sphinx) -> None:
251+
@pytest.mark.parametrize(
252+
("qualname", "docname"),
253+
[("testmod.Class", "test.Class"), ("testmod.Excep2", "test.Excep2")],
254+
)
255+
def test_resolve(app: Sphinx, qualname: str, docname: str) -> None:
252256
"""Test that qualname_overrides affects _last_resolve as expected."""
253257
from docutils.nodes import TextElement, reference
254258
from sphinx.addnodes import pending_xref
@@ -258,10 +262,10 @@ def test_resolve(app: Sphinx) -> None:
258262

259263
# Inventory contains documented name
260264
InventoryAdapter(app.env).main_inventory["py:class"] = {
261-
"test.Class": ("TestProj", "1", "https://x.com", "Class"),
265+
docname: ("TestProj", "1", "https://x.com", docname.split(".")[-1]),
262266
}
263267
# Node contains name from code
264-
node = pending_xref(refdomain="py", reftarget="testmod.Class", reftype="class")
268+
node = pending_xref(refdomain="py", reftarget=qualname, reftype="class")
265269

266270
resolved = _last_resolve(app, app.env, node, TextElement())
267271
assert isinstance(resolved, reference)

0 commit comments

Comments
 (0)