1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
# -*- coding: utf-8 -*-
import os
import sys
from pkgutil import walk_packages
import sphinx
from sphinx.testing.fixtures import make_app, test_params
if sphinx.version_info >= (7, 2):
from pathlib import Path
else:
from sphinx.testing.util import path as Path
if sys.version_info[:2] > (3, 8):
import collections
import collections.abc
collections.Mapping = collections.abc.Mapping
collections.MutableMapping = collections.abc.MutableMapping
SRCDIR = Path(__file__).parent / "docs/basic"
def test_build_html(make_app):
app = make_app(buildername='html', srcdir=SRCDIR)
app.builder.build_all()
def test_build_singlehtml(make_app):
app = make_app(buildername='singlehtml', srcdir=SRCDIR)
app.builder.build_all()
html = (app.outdir / 'index.html').read_text()
assert ('<p>A sphinx extension to include jinja based templates based '
'documentation into a sphinx doc</p>') in html
assert '<p>b</p>' in html
assert '<p>second:a = b</p>' in html
def test_build_latex(make_app):
app = make_app(buildername='latex', srcdir=SRCDIR)
app.builder.build_all()
def test_build_epub(make_app):
app = make_app(buildername='epub', srcdir=SRCDIR)
app.builder.build_all()
def test_build_json(make_app):
app = make_app(buildername='json', srcdir=SRCDIR)
app.builder.build_all()
def test_customize_env(make_app):
app = make_app(buildername='singlehtml', srcdir=SRCDIR)
app.builder.build_all()
html = (app.outdir / 'index.html').read_text()
assert '<h2>Lists' in html
assert 'skipped_string' not in html
for x in [1, 2, 3, 'a', 'b']:
# I have no idea why the <p> tags are missing on 2.7...
if sys.version_info[:2] < (3, 0):
assert '<li><strong>{}</strong></li>'.format(x) in html
else:
assert '<li><p><strong>{}</strong></p></li>'.format(x) in html
def test_header_levels(make_app):
app = make_app(buildername='html', srcdir=SRCDIR)
app.builder.build_all()
html = (app.outdir / 'header_levels.html').read_text()
print(html)
assert '<h1>Header level tests' in html
assert '<h2>same style, but second level' in html
assert '<h3>New style is third level' in html
assert '<h1>same style, same level' in html
assert '<h2>Second level' in html
|