Fix `test_missing_reference` on Windows

This commit is contained in:
Adam Turner 2023-08-12 04:23:48 +01:00
parent 8111a3a211
commit 1a47e3a8be
2 changed files with 3 additions and 7 deletions

View File

@ -175,8 +175,7 @@ def fetch_inventory(app: Sphinx, uri: str, inv: str) -> Inventory:
"""Fetch, parse and return an intersphinx inventory file."""
# both *uri* (base URI of the links to generate) and *inv* (actual
# location of the inventory file) can be local or remote URIs
localuri = '://' not in uri
if not localuri:
if '://' in uri:
# case: inv URI points to remote resource; strip any existing auth
uri = _strip_basic_auth(uri)
try:
@ -198,8 +197,7 @@ def fetch_inventory(app: Sphinx, uri: str, inv: str) -> Inventory:
uri = path.dirname(newinv)
with f:
try:
join = path.join if localuri else posixpath.join
invdata = InventoryFile.load(f, uri, join)
invdata = InventoryFile.load(f, uri, posixpath.join)
except ValueError as exc:
raise ValueError('unknown or unsupported inventory version: %r' % exc) from exc
except Exception as err:
@ -299,7 +297,7 @@ def _create_element_from_result(domain: Domain, inv_name: str | None,
proj, version, uri, dispname = data
if '://' not in uri and node.get('refdoc'):
# get correct path in case of subdirectories
uri = path.join(relative_path(node['refdoc'], '.'), uri)
uri = posixpath.join(relative_path(node['refdoc'], '.'), uri)
if version:
reftitle = _('(in %s v%s)') % (proj, version)
else:

View File

@ -1,7 +1,6 @@
"""Test the intersphinx extension."""
import http.server
import os
from unittest import mock
import pytest
@ -90,7 +89,6 @@ def test_fetch_inventory_redirection(_read_from_url, InventoryFile, app, status,
assert InventoryFile.load.call_args[0][1] == 'http://hostname/'
@pytest.mark.xfail(os.name != 'posix', reason="Path separator mismatch issue")
def test_missing_reference(tmp_path, app, status, warning):
inv_file = tmp_path / 'inventory'
inv_file.write_bytes(inventory_v2)