74 lines
3.1 KiB
Diff
74 lines
3.1 KiB
Diff
|
Index: sphinxcontrib-jquery-4.1/tests/test_jquery_installed.py
|
||
|
===================================================================
|
||
|
--- sphinxcontrib-jquery-4.1.orig/tests/test_jquery_installed.py
|
||
|
+++ sphinxcontrib-jquery-4.1/tests/test_jquery_installed.py
|
||
|
@@ -1,10 +1,9 @@
|
||
|
import base64
|
||
|
import hashlib
|
||
|
-from pathlib import Path
|
||
|
+from pathlib import Path, PosixPath
|
||
|
|
||
|
import pytest
|
||
|
import sphinx
|
||
|
-from sphinx.testing.path import path
|
||
|
from sphinx.testing.util import SphinxTestApp
|
||
|
|
||
|
from sphinxcontrib.jquery import _FILES, _ROOT_DIR # NoQA
|
||
|
@@ -23,12 +22,22 @@ def run_blank_app(srcdir, **kwargs):
|
||
|
return Path(srcdir, "_build", "html")
|
||
|
|
||
|
|
||
|
+class FakePath(PosixPath):
|
||
|
+ @classmethod
|
||
|
+ def _from_parts(cls, args, **kwargs):
|
||
|
+ cls._path = args[0]
|
||
|
+ return PosixPath._from_parts(args, **kwargs)
|
||
|
+
|
||
|
+ def resolve(self, *args, **kwargs):
|
||
|
+ return self._path
|
||
|
+
|
||
|
+
|
||
|
@pytest.fixture(scope="function")
|
||
|
def blank_app(tmpdir, monkeypatch):
|
||
|
def inner(**kwargs):
|
||
|
- return run_blank_app(path(tmpdir), **kwargs)
|
||
|
+ return run_blank_app(Path(tmpdir), **kwargs)
|
||
|
|
||
|
- monkeypatch.setattr("sphinx.application.abspath", lambda x: x)
|
||
|
+ monkeypatch.setattr("sphinx.application._StrPath", FakePath)
|
||
|
yield inner
|
||
|
|
||
|
|
||
|
@@ -38,12 +47,14 @@ def test_jquery_installed_sphinx_ge_60_u
|
||
|
out_dir = blank_app(confoverrides={"extensions": ["sphinxcontrib.jquery"], "jquery_use_sri": True})
|
||
|
|
||
|
text = out_dir.joinpath("index.html").read_text(encoding="utf-8")
|
||
|
+ checksum = '?v=5d32c60e' if sphinx.version_info[:2] >= (7, 1) else ''
|
||
|
assert ('<script '
|
||
|
'integrity="sha384-vtXRMe3mGCbOeY7l30aIg8H9p3GdeSe4IFlP6G8JMa7o7lXvnz3GFKzPxzJdPfGK" '
|
||
|
- 'src="_static/jquery.js"></script>') in text
|
||
|
+ f'src="_static/jquery.js{checksum}"></script>') in text
|
||
|
+ checksum = '?v=2cd50e6c' if sphinx.version_info[:2] >= (7, 1) else ''
|
||
|
assert ('<script '
|
||
|
'integrity="sha384-lSZeSIVKp9myfKbDQ3GkN/KHjUc+mzg17VKDN4Y2kUeBSJioB9QSM639vM9fuY//" '
|
||
|
- 'src="_static/_sphinx_javascript_frameworks_compat.js"></script>') in text
|
||
|
+ f'src="_static/_sphinx_javascript_frameworks_compat.js{checksum}"></script>') in text
|
||
|
|
||
|
static_dir = out_dir / '_static'
|
||
|
assert static_dir.joinpath('jquery.js').is_file()
|
||
|
@@ -56,10 +67,12 @@ def test_jquery_installed_sphinx_ge_60(b
|
||
|
out_dir = blank_app(confoverrides={"extensions": ["sphinxcontrib.jquery"]})
|
||
|
|
||
|
text = out_dir.joinpath("index.html").read_text(encoding="utf-8")
|
||
|
+ checksum = '?v=5d32c60e' if sphinx.version_info[:2] >= (7, 1) else ''
|
||
|
assert ('<script '
|
||
|
- 'src="_static/jquery.js"></script>') in text
|
||
|
+ f'src="_static/jquery.js{checksum}"></script>') in text
|
||
|
+ checksum = '?v=2cd50e6c' if sphinx.version_info[:2] >= (7, 1) else ''
|
||
|
assert ('<script '
|
||
|
- 'src="_static/_sphinx_javascript_frameworks_compat.js"></script>') in text
|
||
|
+ f'src="_static/_sphinx_javascript_frameworks_compat.js{checksum}"></script>') in text
|
||
|
|
||
|
static_dir = out_dir / '_static'
|
||
|
assert static_dir.joinpath('jquery.js').is_file()
|