Skip to content

Commit 40a2cfe

Browse files
committed
Fix Sphinx 6 compatibility in conftest.py rootdir fixture
The sphinx.testing.path.path object in Sphinx <7.2 doesn't have an .absolute() method. The path is already absolute, so we can use it directly without calling .absolute(). This fixes the AttributeError: 'path' object has no attribute 'absolute' error that was causing all 110 tests to fail on Sphinx 6. The version check ensures Sphinx 7.2+ continues to use pathlib.Path with .absolute() as before.
1 parent a973a76 commit 40a2cfe

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tests/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
def rootdir(tmpdir):
1616
from sphinx.testing.path import path
1717

18-
src = path(__file__).parent.absolute() / "books"
18+
# In Sphinx 6, path objects don't have .absolute() method, but they are already absolute
19+
src = path(__file__).parent / "books"
1920
dst = tmpdir.join("books")
2021
shutil.copytree(src, dst)
2122
yield path(dst)

0 commit comments

Comments
 (0)