Skip to content

Commit c70e088

Browse files
authored
Merge pull request #93 from jdillard/fix-path-4
More multi-version Sphinx path support. Use Path.name instead of path.basename only on newer versions of Sphinx testing.
2 parents 4f44c2c + 83f962c commit c70e088

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

tests/test_caching.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from typing import List
55

66
import pytest
7+
import sphinx
78

89
from sphinx.application import Sphinx
910

@@ -13,7 +14,10 @@ def test_image_latex_then_html(
1314
content: Sphinx, tex_images: List[Path], make_app_with_local_user_config
1415
):
1516
box_pdf = tex_images[0]
16-
assert box_pdf.basename() == "box.pdf"
17+
if sphinx.version_info[:2] < (7, 2):
18+
assert box_pdf.basename() == "box.pdf"
19+
else:
20+
assert box_pdf.name == "box.pdf"
1721
assert box_pdf.exists()
1822
html_app = make_app_with_local_user_config(srcdir=content.srcdir)
1923
html_app.build()

tests/test_compat.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from typing import List
33

44
import pytest
5+
import sphinx
56

67
from bs4 import Tag
78

@@ -14,7 +15,10 @@
1415
def test_pdfnoconvert(tex_images: List[Path]):
1516
(image,) = tex_images
1617
# It should not convert a PDF into another format.
17-
assert image.basename() == "box.pdf"
18+
if sphinx.version_info[:2] < (7, 2):
19+
assert image.basename() == "box.pdf"
20+
else:
21+
assert image.name == "box.pdf"
1822

1923

2024
@pytest.mark.sphinx("html", testroot="imgconverter")

tests/test_pdf.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import re
2+
import sphinx
23
from pathlib import Path
34
from typing import List
45

@@ -8,7 +9,10 @@
89
@pytest.mark.sphinx("latex", testroot="image", srcdir="pdf_image")
910
def test_pdf_image(tex_images: List[Path]):
1011
(image,) = tex_images
11-
assert image.basename() == "box.pdf"
12+
if sphinx.version_info[:2] < (7, 2):
13+
assert image.basename() == "box.pdf"
14+
else:
15+
assert image.name == "box.pdf"
1216

1317

1418
@pytest.mark.sphinx("latex", testroot="image", srcdir="pdf_image_crop")

0 commit comments

Comments
 (0)