@@ -94,26 +94,30 @@ def test_register_secondary_url() -> None:
94
94
assert plugin ._secondary_url_map == {"foo" : {"foo.html#foo" : None }}
95
95
96
96
97
- def test_warn_multiple_urls (caplog : pytest .LogCaptureFixture ) -> None :
97
+ @pytest .mark .parametrize ("primary" , [True , False ])
98
+ def test_warn_multiple_urls (caplog : pytest .LogCaptureFixture , primary : bool ) -> None :
98
99
"""Warn when multiple URLs are found for the same identifier."""
99
100
plugin = AutorefsPlugin ()
100
101
plugin .config = AutorefsConfig ()
101
- plugin .register_anchor (identifier = "foo" , page = "foo.html" , primary = True )
102
- plugin .register_anchor (identifier = "foo" , page = "bar.html" , primary = True )
102
+ plugin .register_anchor (identifier = "foo" , page = "foo.html" , primary = primary )
103
+ plugin .register_anchor (identifier = "foo" , page = "bar.html" , primary = primary )
103
104
url_mapper = functools .partial (plugin .get_item_url , from_url = "/hello" )
104
105
# YORE: Bump 2: Replace `, _legacy_refs=False` with `` within line.
105
106
fix_refs ('<autoref identifier="foo">Foo</autoref>' , url_mapper , _legacy_refs = False )
106
- assert "Multiple primary URLs found for 'foo': ['foo.html#foo', 'bar.html#foo']" in caplog .text
107
+ qualifier = "primary" if primary else "secondary"
108
+ assert (f"Multiple { qualifier } URLs found for 'foo': ['foo.html#foo', 'bar.html#foo']" in caplog .text ) is primary
107
109
108
110
109
- def test_use_closest_url (caplog : pytest .LogCaptureFixture ) -> None :
111
+ @pytest .mark .parametrize ("primary" , [True , False ])
112
+ def test_use_closest_url (caplog : pytest .LogCaptureFixture , primary : bool ) -> None :
110
113
"""Use the closest URL when multiple URLs are found for the same identifier."""
111
114
plugin = AutorefsPlugin ()
112
115
plugin .config = AutorefsConfig ()
113
116
plugin .config .resolve_closest = True
114
- plugin .register_anchor (identifier = "foo" , page = "foo.html" , primary = True )
115
- plugin .register_anchor (identifier = "foo" , page = "bar.html" , primary = True )
117
+ plugin .register_anchor (identifier = "foo" , page = "foo.html" , primary = primary )
118
+ plugin .register_anchor (identifier = "foo" , page = "bar.html" , primary = primary )
116
119
url_mapper = functools .partial (plugin .get_item_url , from_url = "/hello" )
117
120
# YORE: Bump 2: Replace `, _legacy_refs=False` with `` within line.
118
121
fix_refs ('<autoref identifier="foo">Foo</autoref>' , url_mapper , _legacy_refs = False )
119
- assert "Multiple primary URLs found for 'foo': ['foo.html#foo', 'bar.html#foo']" not in caplog .text
122
+ qualifier = "primary" if primary else "secondary"
123
+ assert f"Multiple { qualifier } URLs found for 'foo': ['foo.html#foo', 'bar.html#foo']" not in caplog .text
0 commit comments