1111
1212from mkdocs_autorefs .plugin import AutorefsConfig , AutorefsPlugin
1313from mkdocs_autorefs .references import fix_refs
14+ from tests .helpers import create_page
1415
1516
1617def test_url_registration () -> None :
1718 """Check that URLs can be registered, then obtained."""
1819 plugin = AutorefsPlugin ()
19- plugin .register_anchor (identifier = "foo" , page = "foo1.html" , primary = True )
20+ plugin .register_anchor (identifier = "foo" , page = create_page ( "foo1.html" ) , primary = True )
2021 plugin .register_url (identifier = "bar" , url = "https://example.org/bar.html" )
2122
2223 assert plugin .get_item_url ("foo" ) == ("foo1.html#foo" , None )
@@ -28,7 +29,7 @@ def test_url_registration() -> None:
2829def test_url_registration_with_from_url () -> None :
2930 """Check that URLs can be registered, then obtained, relative to a page."""
3031 plugin = AutorefsPlugin ()
31- plugin .register_anchor (identifier = "foo" , page = "foo1.html" , primary = True )
32+ plugin .register_anchor (identifier = "foo" , page = create_page ( "foo1.html" ) , primary = True )
3233 plugin .register_url (identifier = "bar" , url = "https://example.org/bar.html" )
3334
3435 assert plugin .get_item_url ("foo" , from_url = "a/b.html" ) == ("../foo1.html#foo" , None )
@@ -41,7 +42,7 @@ def test_url_registration_with_from_url() -> None:
4142def test_url_registration_with_fallback () -> None :
4243 """Check that URLs can be registered, then obtained through a fallback."""
4344 plugin = AutorefsPlugin ()
44- plugin .register_anchor (identifier = "foo" , page = "foo1.html" , primary = True )
45+ plugin .register_anchor (identifier = "foo" , page = create_page ( "foo1.html" ) , primary = True )
4546 plugin .register_url (identifier = "bar" , url = "https://example.org/bar.html" )
4647
4748 # URL map will be updated with baz -> foo1.html#foo
@@ -60,7 +61,7 @@ def test_url_registration_with_fallback() -> None:
6061def test_dont_make_relative_urls_relative_again () -> None :
6162 """Check that URLs are not made relative more than once."""
6263 plugin = AutorefsPlugin ()
63- plugin .register_anchor (identifier = "foo.bar.baz" , page = "foo/bar/baz.html" , primary = True )
64+ plugin .register_anchor (identifier = "foo.bar.baz" , page = create_page ( "foo/bar/baz.html" ) , primary = True )
6465
6566 for _ in range (2 ):
6667 assert plugin .get_item_url ("foo.bar.baz" , from_url = "baz/bar/foo.html" ) == (
@@ -96,7 +97,7 @@ def test_find_closest_url(base: str, urls: list[str], expected: str) -> None:
9697def test_register_secondary_url () -> None :
9798 """Test registering secondary URLs."""
9899 plugin = AutorefsPlugin ()
99- plugin .register_anchor (identifier = "foo" , page = "foo.html" , primary = False )
100+ plugin .register_anchor (identifier = "foo" , page = create_page ( "foo.html" ) , primary = False )
100101 assert plugin ._secondary_url_map == {"foo" : ["foo.html#foo" ]}
101102
102103
@@ -105,8 +106,8 @@ def test_warn_multiple_urls(caplog: pytest.LogCaptureFixture, primary: bool) ->
105106 """Warn when multiple URLs are found for the same identifier."""
106107 plugin = AutorefsPlugin ()
107108 plugin .config = AutorefsConfig ()
108- plugin .register_anchor (identifier = "foo" , page = "foo.html" , primary = primary )
109- plugin .register_anchor (identifier = "foo" , page = "bar.html" , primary = primary )
109+ plugin .register_anchor (identifier = "foo" , page = create_page ( "foo.html" ) , primary = primary )
110+ plugin .register_anchor (identifier = "foo" , page = create_page ( "bar.html" ) , primary = primary )
110111 url_mapper = functools .partial (plugin .get_item_url , from_url = "/hello" )
111112 # YORE: Bump 2: Replace `, _legacy_refs=False` with `` within line.
112113 fix_refs ('<autoref identifier="foo">Foo</autoref>' , url_mapper , _legacy_refs = False )
@@ -120,8 +121,8 @@ def test_use_closest_url(caplog: pytest.LogCaptureFixture, primary: bool) -> Non
120121 plugin = AutorefsPlugin ()
121122 plugin .config = AutorefsConfig ()
122123 plugin .config .resolve_closest = True
123- plugin .register_anchor (identifier = "foo" , page = "foo.html" , primary = primary )
124- plugin .register_anchor (identifier = "foo" , page = "bar.html" , primary = primary )
124+ plugin .register_anchor (identifier = "foo" , page = create_page ( "foo.html" ) , primary = primary )
125+ plugin .register_anchor (identifier = "foo" , page = create_page ( "bar.html" ) , primary = primary )
125126 url_mapper = functools .partial (plugin .get_item_url , from_url = "/hello" )
126127 # YORE: Bump 2: Replace `, _legacy_refs=False` with `` within line.
127128 fix_refs ('<autoref identifier="foo">Foo</autoref>' , url_mapper , _legacy_refs = False )
0 commit comments