| 1 |
"""Test sphinx.ext.githubpages extension.""" |
| 2 |
|
| 3 |
from __future__ import annotations |
| 4 |
|
| 5 |
from typing import TYPE_CHECKING |
| 6 |
|
| 7 |
import pytest |
| 8 |
|
| 9 |
from sphinx.testing.util import SphinxTestApp |
| 10 |
|
| 11 |
if TYPE_CHECKING: |
| 12 |
from sphinx.testing.util import SphinxTestApp |
| 13 |
|
| 14 |
|
| 15 |
@pytest.mark.sphinx('html', testroot='ext-githubpages') |
| 16 |
def test_githubpages(app: SphinxTestApp) -> None: |
| 17 |
app.build(force_all=True) |
| 18 |
assert (app.outdir / '.nojekyll').exists() |
| 19 |
assert not (app.outdir / 'CNAME').exists() |
| 20 |
|
| 21 |
|
| 22 |
@pytest.mark.sphinx( |
| 23 |
'html', |
| 24 |
testroot='ext-githubpages', |
| 25 |
confoverrides={'html_baseurl': 'https://sphinx-doc.github.io'}, |
| 26 |
) |
| 27 |
def test_no_cname_for_github_io_domain(app: SphinxTestApp) -> None: |
| 28 |
app.build(force_all=True) |
| 29 |
assert (app.outdir / '.nojekyll').exists() |
| 30 |
assert not (app.outdir / 'CNAME').exists() |
| 31 |
|
| 32 |
|
| 33 |
@pytest.mark.sphinx( |
| 34 |
'html', |
| 35 |
testroot='ext-githubpages', |
| 36 |
confoverrides={'html_baseurl': 'https://sphinx-doc.org'}, |
| 37 |
) |
| 38 |
def test_cname_for_custom_domain(app: SphinxTestApp) -> None: |
| 39 |
app.build(force_all=True) |
| 40 |
assert (app.outdir / '.nojekyll').exists() |
| 41 |
assert (app.outdir / 'CNAME').read_text(encoding='utf8') == 'sphinx-doc.org' |