Skip to content

Commit 6359d5b

Browse files
authored
Add test for absolute paths. (#363)
Fixes #361
1 parent b8983b5 commit 6359d5b

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

src/sphinxcontrib/bibtex/bibfile.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
from pybtex.database.input.bibtex import Parser
2626
from sphinx.util.logging import getLogger
2727

28-
2928
logger = getLogger(__name__)
3029

3130

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
extensions = ["sphinxcontrib.bibtex"]
2+
exclude_patterns = ["_build"]
3+
# bibtex_bibfiles set with absolute path through confoverrides
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.. bibliography::
2+
:all:

test/test_bibfiles.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import re
22
import shutil
33
import time
4+
from pathlib import Path
45
from test.common import html_citations
56

67
import pytest
@@ -139,3 +140,23 @@ def test_bibfiles_multiple_keys(app, warning) -> None:
139140
def test_bibfiles_crossref(app, warning) -> None:
140141
app.build()
141142
assert not warning.getvalue()
143+
144+
145+
@pytest.mark.sphinx(
146+
"html",
147+
testroot="bibfiles_absolute_path",
148+
confoverrides={
149+
"bibtex_bibfiles": [
150+
Path(__file__).parent / "roots" / "test-debug_minimal_example" / "refs.bib"
151+
],
152+
},
153+
)
154+
def test_bibfiles_absolute_path(app, warning) -> None:
155+
app.build()
156+
assert not warning.getvalue()
157+
assert re.search(
158+
"parsing bibtex file .*test-debug_minimal_example.* parsed 1 entries",
159+
app._status.getvalue(),
160+
)
161+
output = (app.outdir / "index.html").read_text()
162+
assert len(html_citations().findall(output)) == 1

0 commit comments

Comments
 (0)