mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
.read_text() -> .read_text(encoding='utf8')
This commit is contained in:
@@ -40,7 +40,7 @@ def nonascii_srcdir(request, rootdir, sphinx_test_tempdir):
|
||||
"""))
|
||||
|
||||
root_doc = srcdir / 'index.txt'
|
||||
root_doc.write_text(root_doc.read_text() + dedent("""
|
||||
root_doc.write_text(root_doc.read_text(encoding='utf8') + dedent("""
|
||||
.. toctree::
|
||||
|
||||
%(test_name)s/%(test_name)s
|
||||
|
||||
@@ -8,7 +8,7 @@ def test_build(app):
|
||||
app.build()
|
||||
|
||||
# TODO: Use better checking of html content
|
||||
htmltext = (app.outdir / 'changes.html').read_text()
|
||||
htmltext = (app.outdir / 'changes.html').read_text(encoding='utf8')
|
||||
assert 'New in version 0.6: Some funny stuff.' in htmltext
|
||||
assert 'Changed in version 0.6: Even more funny stuff.' in htmltext
|
||||
assert 'Deprecated since version 0.6: Boring stuff.' in htmltext
|
||||
|
||||
@@ -17,7 +17,7 @@ def test_dirhtml(app, status, warning):
|
||||
assert (app.outdir / 'foo/foo_2/index.html').exists()
|
||||
assert (app.outdir / 'bar/index.html').exists()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert 'href="foo/"' in content
|
||||
assert 'href="foo/foo_1/"' in content
|
||||
assert 'href="foo/foo_2/"' in content
|
||||
|
||||
@@ -57,11 +57,11 @@ class EPUBElementTree:
|
||||
@pytest.mark.sphinx('epub', testroot='basic')
|
||||
def test_build_epub(app):
|
||||
app.build()
|
||||
assert (app.outdir / 'mimetype').read_text() == 'application/epub+zip'
|
||||
assert (app.outdir / 'mimetype').read_text(encoding='utf8') == 'application/epub+zip'
|
||||
assert (app.outdir / 'META-INF' / 'container.xml').exists()
|
||||
|
||||
# toc.ncx
|
||||
toc = EPUBElementTree.fromstring((app.outdir / 'toc.ncx').read_text())
|
||||
toc = EPUBElementTree.fromstring((app.outdir / 'toc.ncx').read_text(encoding='utf8'))
|
||||
assert toc.find("./ncx:docTitle/ncx:text").text == 'Python'
|
||||
|
||||
# toc.ncx / head
|
||||
@@ -81,7 +81,7 @@ def test_build_epub(app):
|
||||
assert navlabel.text == 'The basic Sphinx documentation for testing'
|
||||
|
||||
# content.opf
|
||||
opf = EPUBElementTree.fromstring((app.outdir / 'content.opf').read_text())
|
||||
opf = EPUBElementTree.fromstring((app.outdir / 'content.opf').read_text(encoding='utf8'))
|
||||
|
||||
# content.opf / metadata
|
||||
metadata = opf.find("./idpf:metadata")
|
||||
@@ -133,7 +133,7 @@ def test_build_epub(app):
|
||||
assert reference.get('href') == 'index.xhtml'
|
||||
|
||||
# nav.xhtml
|
||||
nav = EPUBElementTree.fromstring((app.outdir / 'nav.xhtml').read_text())
|
||||
nav = EPUBElementTree.fromstring((app.outdir / 'nav.xhtml').read_text(encoding='utf8'))
|
||||
assert nav.attrib == {'lang': 'en',
|
||||
'{http://www.w3.org/XML/1998/namespace}lang': 'en'}
|
||||
assert nav.find("./xhtml:head/xhtml:title").text == 'Table of Contents'
|
||||
@@ -153,7 +153,7 @@ def test_epub_cover(app):
|
||||
app.build()
|
||||
|
||||
# content.opf / metadata
|
||||
opf = EPUBElementTree.fromstring((app.outdir / 'content.opf').read_text())
|
||||
opf = EPUBElementTree.fromstring((app.outdir / 'content.opf').read_text(encoding='utf8'))
|
||||
cover_image = opf.find("./idpf:manifest/idpf:item[@href='%s']" % app.config.epub_cover[0])
|
||||
cover = opf.find("./idpf:metadata/idpf:meta[@name='cover']")
|
||||
assert cover
|
||||
@@ -276,7 +276,7 @@ def test_epub_writing_mode(app):
|
||||
app.build()
|
||||
|
||||
# horizontal / page-progression-direction
|
||||
opf = EPUBElementTree.fromstring((app.outdir / 'content.opf').read_text())
|
||||
opf = EPUBElementTree.fromstring((app.outdir / 'content.opf').read_text(encoding='utf8'))
|
||||
assert opf.find("./idpf:spine").get('page-progression-direction') == 'ltr'
|
||||
|
||||
# horizontal / ibooks:scroll-axis
|
||||
@@ -284,7 +284,7 @@ def test_epub_writing_mode(app):
|
||||
assert metadata.find("./idpf:meta[@property='ibooks:scroll-axis']").text == 'vertical'
|
||||
|
||||
# horizontal / writing-mode (CSS)
|
||||
css = (app.outdir / '_static' / 'epub.css').read_text()
|
||||
css = (app.outdir / '_static' / 'epub.css').read_text(encoding='utf8')
|
||||
assert 'writing-mode: horizontal-tb;' in css
|
||||
|
||||
# vertical
|
||||
@@ -293,7 +293,7 @@ def test_epub_writing_mode(app):
|
||||
app.build()
|
||||
|
||||
# vertical / page-progression-direction
|
||||
opf = EPUBElementTree.fromstring((app.outdir / 'content.opf').read_text())
|
||||
opf = EPUBElementTree.fromstring((app.outdir / 'content.opf').read_text(encoding='utf8'))
|
||||
assert opf.find("./idpf:spine").get('page-progression-direction') == 'rtl'
|
||||
|
||||
# vertical / ibooks:scroll-axis
|
||||
@@ -301,7 +301,7 @@ def test_epub_writing_mode(app):
|
||||
assert metadata.find("./idpf:meta[@property='ibooks:scroll-axis']").text == 'horizontal'
|
||||
|
||||
# vertical / writing-mode (CSS)
|
||||
css = (app.outdir / '_static' / 'epub.css').read_text()
|
||||
css = (app.outdir / '_static' / 'epub.css').read_text(encoding='utf8')
|
||||
assert 'writing-mode: vertical-rl;' in css
|
||||
|
||||
|
||||
@@ -309,7 +309,7 @@ def test_epub_writing_mode(app):
|
||||
def test_epub_anchor_id(app):
|
||||
app.build()
|
||||
|
||||
html = (app.outdir / 'index.xhtml').read_text()
|
||||
html = (app.outdir / 'index.xhtml').read_text(encoding='utf8')
|
||||
assert ('<p id="std-setting-STATICFILES_FINDERS">'
|
||||
'blah blah blah</p>' in html)
|
||||
assert ('<span id="std-setting-STATICFILES_SECTION"></span>'
|
||||
@@ -322,7 +322,7 @@ def test_epub_assets(app):
|
||||
app.builder.build_all()
|
||||
|
||||
# epub_sytlesheets (same as html_css_files)
|
||||
content = (app.outdir / 'index.xhtml').read_text()
|
||||
content = (app.outdir / 'index.xhtml').read_text(encoding='utf8')
|
||||
assert ('<link rel="stylesheet" type="text/css" href="_static/css/style.css" />'
|
||||
in content)
|
||||
assert ('<link media="print" rel="stylesheet" title="title" type="text/css" '
|
||||
@@ -335,7 +335,7 @@ def test_epub_css_files(app):
|
||||
app.builder.build_all()
|
||||
|
||||
# epub_css_files
|
||||
content = (app.outdir / 'index.xhtml').read_text()
|
||||
content = (app.outdir / 'index.xhtml').read_text(encoding='utf8')
|
||||
assert '<link rel="stylesheet" type="text/css" href="_static/css/epub.css" />' in content
|
||||
|
||||
# files in html_css_files are not outputted
|
||||
@@ -350,7 +350,7 @@ def test_html_download_role(app, status, warning):
|
||||
app.build()
|
||||
assert not (app.outdir / '_downloads' / 'dummy.dat').exists()
|
||||
|
||||
content = (app.outdir / 'index.xhtml').read_text()
|
||||
content = (app.outdir / 'index.xhtml').read_text(encoding='utf8')
|
||||
assert ('<li><p><code class="xref download docutils literal notranslate">'
|
||||
'<span class="pre">dummy.dat</span></code></p></li>' in content)
|
||||
assert ('<li><p><code class="xref download docutils literal notranslate">'
|
||||
|
||||
@@ -23,7 +23,7 @@ def test_build_gettext(app):
|
||||
assert (app.outdir / 'subdir.pot').isfile()
|
||||
|
||||
# regression test for issue #960
|
||||
catalog = (app.outdir / 'markup.pot').read_text()
|
||||
catalog = (app.outdir / 'markup.pot').read_text(encoding='utf8')
|
||||
assert 'msgid "something, something else, something more"' in catalog
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ def test_gettext_index_entries(app):
|
||||
return m.groups()[0]
|
||||
return None
|
||||
|
||||
pot = (app.outdir / 'index_entries.pot').read_text()
|
||||
pot = (app.outdir / 'index_entries.pot').read_text(encoding='utf8')
|
||||
msgids = [_f for _f in map(msgid_getter, pot.splitlines()) if _f]
|
||||
|
||||
expected_msgids = [
|
||||
@@ -125,7 +125,7 @@ def test_gettext_disable_index_entries(app):
|
||||
return m.groups()[0]
|
||||
return None
|
||||
|
||||
pot = (app.outdir / 'index_entries.pot').read_text()
|
||||
pot = (app.outdir / 'index_entries.pot').read_text(encoding='utf8')
|
||||
msgids = [_f for _f in map(msgid_getter, pot.splitlines()) if _f]
|
||||
|
||||
expected_msgids = [
|
||||
@@ -148,7 +148,7 @@ def test_gettext_template(app):
|
||||
app.builder.build_all()
|
||||
assert (app.outdir / 'sphinx.pot').isfile()
|
||||
|
||||
result = (app.outdir / 'sphinx.pot').read_text()
|
||||
result = (app.outdir / 'sphinx.pot').read_text(encoding='utf8')
|
||||
assert "Welcome" in result
|
||||
assert "Sphinx %(version)s" in result
|
||||
|
||||
@@ -158,7 +158,7 @@ def test_gettext_template_msgid_order_in_sphinxpot(app):
|
||||
app.builder.build_all()
|
||||
assert (app.outdir / 'sphinx.pot').isfile()
|
||||
|
||||
result = (app.outdir / 'sphinx.pot').read_text()
|
||||
result = (app.outdir / 'sphinx.pot').read_text(encoding='utf8')
|
||||
assert re.search(
|
||||
('msgid "Template 1".*'
|
||||
'msgid "This is Template 1\\.".*'
|
||||
@@ -176,7 +176,7 @@ def test_build_single_pot(app):
|
||||
|
||||
assert (app.outdir / 'documentation.pot').isfile()
|
||||
|
||||
result = (app.outdir / 'documentation.pot').read_text()
|
||||
result = (app.outdir / 'documentation.pot').read_text(encoding='utf8')
|
||||
assert re.search(
|
||||
('msgid "Todo".*'
|
||||
'msgid "Like footnotes.".*'
|
||||
|
||||
@@ -480,7 +480,7 @@ def test_html_download(app):
|
||||
app.build()
|
||||
|
||||
# subdir/includes.html
|
||||
result = (app.outdir / 'subdir' / 'includes.html').read_text()
|
||||
result = (app.outdir / 'subdir' / 'includes.html').read_text(encoding='utf8')
|
||||
pattern = ('<a class="reference download internal" download="" '
|
||||
'href="../(_downloads/.*/img.png)">')
|
||||
matched = re.search(pattern, result)
|
||||
@@ -489,7 +489,7 @@ def test_html_download(app):
|
||||
filename = matched.group(1)
|
||||
|
||||
# includes.html
|
||||
result = (app.outdir / 'includes.html').read_text()
|
||||
result = (app.outdir / 'includes.html').read_text(encoding='utf8')
|
||||
pattern = ('<a class="reference download internal" download="" '
|
||||
'href="(_downloads/.*/img.png)">')
|
||||
matched = re.search(pattern, result)
|
||||
@@ -512,7 +512,7 @@ def test_html_download_role(app, status, warning):
|
||||
digest_another = md5(b'another/dummy.dat').hexdigest()
|
||||
assert (app.outdir / '_downloads' / digest_another / 'dummy.dat').exists()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert (('<li><p><a class="reference download internal" download="" '
|
||||
'href="_downloads/%s/dummy.dat">'
|
||||
'<code class="xref download docutils literal notranslate">'
|
||||
@@ -694,7 +694,7 @@ def test_numfig_disabled(app, cached_etree_parse, fname, expect):
|
||||
def test_numfig_without_numbered_toctree_warn(app, warning):
|
||||
app.build()
|
||||
# remove :numbered: option
|
||||
index = (app.srcdir / 'index.rst').read_text()
|
||||
index = (app.srcdir / 'index.rst').read_text(encoding='utf8')
|
||||
index = re.sub(':numbered:.*', '', index)
|
||||
(app.srcdir / 'index.rst').write_text(index)
|
||||
app.builder.build_all()
|
||||
@@ -782,7 +782,7 @@ def test_numfig_without_numbered_toctree_warn(app, warning):
|
||||
confoverrides={'numfig': True})
|
||||
def test_numfig_without_numbered_toctree(app, cached_etree_parse, fname, expect):
|
||||
# remove :numbered: option
|
||||
index = (app.srcdir / 'index.rst').read_text()
|
||||
index = (app.srcdir / 'index.rst').read_text(encoding='utf8')
|
||||
index = re.sub(':numbered:.*', '', index)
|
||||
(app.srcdir / 'index.rst').write_text(index)
|
||||
|
||||
@@ -1172,7 +1172,7 @@ def test_html_assets(app):
|
||||
assert not (app.outdir / '_static' / '.htaccess').exists()
|
||||
assert not (app.outdir / '_static' / '.htpasswd').exists()
|
||||
assert (app.outdir / '_static' / 'API.html').exists()
|
||||
assert (app.outdir / '_static' / 'API.html').read_text() == 'Sphinx-1.4.4'
|
||||
assert (app.outdir / '_static' / 'API.html').read_text(encoding='utf8') == 'Sphinx-1.4.4'
|
||||
assert (app.outdir / '_static' / 'css' / 'style.css').exists()
|
||||
assert (app.outdir / '_static' / 'js' / 'custom.js').exists()
|
||||
assert (app.outdir / '_static' / 'rimg.png').exists()
|
||||
@@ -1193,7 +1193,7 @@ def test_html_assets(app):
|
||||
assert not (app.outdir / 'subdir' / '.htpasswd').exists()
|
||||
|
||||
# html_css_files
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert '<link rel="stylesheet" type="text/css" href="_static/css/style.css" />' in content
|
||||
assert ('<link media="print" rel="stylesheet" title="title" type="text/css" '
|
||||
'href="https://example.com/custom.css" />' in content)
|
||||
@@ -1216,7 +1216,7 @@ def test_assets_order(app):
|
||||
app.add_js_file('lazy.js', priority=900)
|
||||
|
||||
app.builder.build_all()
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
||||
# css_files
|
||||
expected = ['_static/early.css', '_static/pygments.css', '_static/alabaster.css',
|
||||
@@ -1240,7 +1240,7 @@ def test_javscript_loading_method(app):
|
||||
app.add_js_file('late.js', loading_method='defer')
|
||||
|
||||
app.builder.build_all()
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
||||
assert '<script src="_static/normal.js"></script>' in content
|
||||
assert '<script async="async" src="_static/early.js"></script>' in content
|
||||
@@ -1275,7 +1275,7 @@ def test_html_sourcelink_suffix_empty(app):
|
||||
def test_html_entity(app):
|
||||
app.builder.build_all()
|
||||
valid_entities = {'amp', 'lt', 'gt', 'quot', 'apos'}
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
for entity in re.findall(r'&([a-z]+);', content, re.M):
|
||||
assert entity not in valid_entities
|
||||
|
||||
@@ -1317,7 +1317,7 @@ def test_html_inventory(app):
|
||||
@pytest.mark.sphinx('html', testroot='images', confoverrides={'html_sourcelink_suffix': ''})
|
||||
def test_html_anchor_for_figure(app):
|
||||
app.builder.build_all()
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
if docutils.__version_info__ < (0, 17):
|
||||
assert ('<p class="caption"><span class="caption-text">The caption of pic</span>'
|
||||
'<a class="headerlink" href="#id1" title="Permalink to this image">¶</a></p>'
|
||||
@@ -1331,7 +1331,7 @@ def test_html_anchor_for_figure(app):
|
||||
@pytest.mark.sphinx('html', testroot='directives-raw')
|
||||
def test_html_raw_directive(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'index.html').read_text()
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
||||
# standard case
|
||||
assert 'standalone raw directive (HTML)' in result
|
||||
@@ -1375,7 +1375,7 @@ def test_alternate_stylesheets(app, cached_etree_parse, fname, expect):
|
||||
@pytest.mark.sphinx('html', testroot='html_style')
|
||||
def test_html_style(app, status, warning):
|
||||
app.build()
|
||||
result = (app.outdir / 'index.html').read_text()
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert '<link rel="stylesheet" type="text/css" href="_static/default.css" />' in result
|
||||
assert ('<link rel="stylesheet" type="text/css" href="_static/alabaster.css" />'
|
||||
not in result)
|
||||
@@ -1385,7 +1385,7 @@ def test_html_style(app, status, warning):
|
||||
def test_html_remote_images(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
result = (app.outdir / 'index.html').read_text()
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert ('<img alt="https://www.python.org/static/img/python-logo.png" '
|
||||
'src="https://www.python.org/static/img/python-logo.png" />' in result)
|
||||
assert not (app.outdir / 'python-logo.png').exists()
|
||||
@@ -1395,7 +1395,7 @@ def test_html_remote_images(app, status, warning):
|
||||
def test_html_remote_logo(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
result = (app.outdir / 'index.html').read_text()
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert ('<img class="logo" src="https://www.python.org/static/img/python-logo.png" alt="Logo"/>' in result)
|
||||
assert ('<link rel="shortcut icon" href="https://www.python.org/static/favicon.ico"/>' in result)
|
||||
assert not (app.outdir / 'python-logo.png').exists()
|
||||
@@ -1405,7 +1405,7 @@ def test_html_remote_logo(app, status, warning):
|
||||
def test_html_local_logo(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
result = (app.outdir / 'index.html').read_text()
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert ('<img class="logo" src="_static/img.png" alt="Logo"/>' in result)
|
||||
assert (app.outdir / '_static/img.png').exists()
|
||||
|
||||
@@ -1416,7 +1416,7 @@ def test_html_sidebar(app, status, warning):
|
||||
|
||||
# default for alabaster
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'index.html').read_text()
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert ('<div class="sphinxsidebar" role="navigation" '
|
||||
'aria-label="main navigation">' in result)
|
||||
assert '<h1 class="logo"><a href="#">Python</a></h1>' in result
|
||||
@@ -1431,7 +1431,7 @@ def test_html_sidebar(app, status, warning):
|
||||
# only relations.html
|
||||
app.config.html_sidebars = {'**': ['relations.html']}
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'index.html').read_text()
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert ('<div class="sphinxsidebar" role="navigation" '
|
||||
'aria-label="main navigation">' in result)
|
||||
assert '<h1 class="logo"><a href="#">Python</a></h1>' not in result
|
||||
@@ -1445,7 +1445,7 @@ def test_html_sidebar(app, status, warning):
|
||||
# no sidebars
|
||||
app.config.html_sidebars = {'**': []}
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'index.html').read_text()
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert ('<div class="sphinxsidebar" role="navigation" '
|
||||
'aria-label="main navigation">' not in result)
|
||||
assert '<h1 class="logo"><a href="#">Python</a></h1>' not in result
|
||||
@@ -1476,10 +1476,10 @@ def test_html_manpage(app, cached_etree_parse, fname, expect):
|
||||
def test_html_baseurl(app, status, warning):
|
||||
app.build()
|
||||
|
||||
result = (app.outdir / 'index.html').read_text()
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert '<link rel="canonical" href="https://example.com/index.html" />' in result
|
||||
|
||||
result = (app.outdir / 'qux' / 'index.html').read_text()
|
||||
result = (app.outdir / 'qux' / 'index.html').read_text(encoding='utf8')
|
||||
assert '<link rel="canonical" href="https://example.com/qux/index.html" />' in result
|
||||
|
||||
|
||||
@@ -1489,10 +1489,10 @@ def test_html_baseurl(app, status, warning):
|
||||
def test_html_baseurl_and_html_file_suffix(app, status, warning):
|
||||
app.build()
|
||||
|
||||
result = (app.outdir / 'index.htm').read_text()
|
||||
result = (app.outdir / 'index.htm').read_text(encoding='utf8')
|
||||
assert '<link rel="canonical" href="https://example.com/subdir/index.htm" />' in result
|
||||
|
||||
result = (app.outdir / 'qux' / 'index.htm').read_text()
|
||||
result = (app.outdir / 'qux' / 'index.htm').read_text(encoding='utf8')
|
||||
assert '<link rel="canonical" href="https://example.com/subdir/qux/index.htm" />' in result
|
||||
|
||||
|
||||
@@ -1609,7 +1609,7 @@ def test_validate_html_static_path(app):
|
||||
@pytest.mark.sphinx(testroot='html_scaled_image_link')
|
||||
def test_html_scaled_image_link(app):
|
||||
app.build()
|
||||
context = (app.outdir / 'index.html').read_text()
|
||||
context = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
||||
# no scaled parameters
|
||||
assert re.search('\n<img alt="_images/img.png" src="_images/img.png" />', context)
|
||||
@@ -1629,7 +1629,7 @@ def test_html_scaled_image_link(app):
|
||||
confoverrides={'html_codeblock_linenos_style': 'table'})
|
||||
def test_html_codeblock_linenos_style_table(app):
|
||||
app.build()
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
||||
if PYGMENTS_VERSION >= (2, 8):
|
||||
assert ('<div class="linenodiv"><pre><span class="normal">1</span>\n'
|
||||
@@ -1644,7 +1644,7 @@ def test_html_codeblock_linenos_style_table(app):
|
||||
confoverrides={'html_codeblock_linenos_style': 'inline'})
|
||||
def test_html_codeblock_linenos_style_inline(app):
|
||||
app.build()
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
||||
if PYGMENTS_VERSION > (2, 7):
|
||||
assert '<span class="linenos">1</span>' in content
|
||||
@@ -1689,7 +1689,7 @@ def test_highlight_options_old(app):
|
||||
confoverrides={'html_permalinks': False})
|
||||
def test_html_permalink_disable(app):
|
||||
app.build()
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
||||
assert '<h1>The basic Sphinx documentation for testing</h1>' in content
|
||||
|
||||
@@ -1698,7 +1698,7 @@ def test_html_permalink_disable(app):
|
||||
confoverrides={'html_permalinks_icon': '<span>[PERMALINK]</span>'})
|
||||
def test_html_permalink_icon(app):
|
||||
app.build()
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
||||
assert ('<h1>The basic Sphinx documentation for testing<a class="headerlink" '
|
||||
'href="#the-basic-sphinx-documentation-for-testing" '
|
||||
@@ -1708,6 +1708,6 @@ def test_html_permalink_icon(app):
|
||||
@pytest.mark.sphinx('html', testroot='html_signaturereturn_icon')
|
||||
def test_html_signaturereturn_icon(app):
|
||||
app.build()
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
||||
assert ('<span class="sig-return-icon">→</span>' in content)
|
||||
|
||||
@@ -104,7 +104,7 @@ def test_build_latex_doc(app, status, warning, engine, docclass):
|
||||
@pytest.mark.sphinx('latex')
|
||||
def test_writer(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'sphinxtests.tex').read_text()
|
||||
result = (app.outdir / 'sphinxtests.tex').read_text(encoding='utf8')
|
||||
|
||||
assert ('\\begin{sphinxfigure-in-table}\n\\centering\n\\capstart\n'
|
||||
'\\noindent\\sphinxincludegraphics{{img}.png}\n'
|
||||
@@ -147,7 +147,7 @@ def test_latex_warnings(app, status, warning):
|
||||
@pytest.mark.sphinx('latex', testroot='basic')
|
||||
def test_latex_basic(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'test.tex').read_text()
|
||||
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -240,7 +240,7 @@ def test_latex_theme_options(app, status, warning):
|
||||
@pytest.mark.sphinx('latex', testroot='basic', confoverrides={'language': 'zh'})
|
||||
def test_latex_additional_settings_for_language_code(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'test.tex').read_text()
|
||||
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -250,7 +250,7 @@ def test_latex_additional_settings_for_language_code(app, status, warning):
|
||||
@pytest.mark.sphinx('latex', testroot='basic', confoverrides={'language': 'el'})
|
||||
def test_latex_additional_settings_for_greek(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'test.tex').read_text()
|
||||
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -261,7 +261,7 @@ def test_latex_additional_settings_for_greek(app, status, warning):
|
||||
@pytest.mark.sphinx('latex', testroot='latex-title')
|
||||
def test_latex_title_after_admonitions(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'test.tex').read_text()
|
||||
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -272,7 +272,7 @@ def test_latex_title_after_admonitions(app, status, warning):
|
||||
confoverrides={'release': '1.0_0'})
|
||||
def test_latex_release(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'test.tex').read_text()
|
||||
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -284,7 +284,7 @@ def test_latex_release(app, status, warning):
|
||||
confoverrides={'numfig': True})
|
||||
def test_numref(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -310,7 +310,7 @@ def test_numref(app, status, warning):
|
||||
'\\nameref{\\detokenize{foo:foo}}}') in result
|
||||
|
||||
# sphinxmessages.sty
|
||||
result = (app.outdir / 'sphinxmessages.sty').read_text()
|
||||
result = (app.outdir / 'sphinxmessages.sty').read_text(encoding='utf8')
|
||||
print(result)
|
||||
assert r'\addto\captionsenglish{\renewcommand{\figurename}{Fig.\@{} }}' in result
|
||||
assert r'\addto\captionsenglish{\renewcommand{\tablename}{Table }}' in result
|
||||
@@ -326,7 +326,7 @@ def test_numref(app, status, warning):
|
||||
'section': 'SECTION-%s'}})
|
||||
def test_numref_with_prefix1(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -358,7 +358,7 @@ def test_numref_with_prefix1(app, status, warning):
|
||||
'\\nameref{\\detokenize{foo:foo}}}') in result
|
||||
|
||||
# sphinxmessages.sty
|
||||
result = (app.outdir / 'sphinxmessages.sty').read_text()
|
||||
result = (app.outdir / 'sphinxmessages.sty').read_text(encoding='utf8')
|
||||
print(result)
|
||||
assert r'\addto\captionsenglish{\renewcommand{\figurename}{Figure:}}' in result
|
||||
assert r'\addto\captionsenglish{\renewcommand{\tablename}{Tab\_}}' in result
|
||||
@@ -374,7 +374,7 @@ def test_numref_with_prefix1(app, status, warning):
|
||||
'section': 'SECTION_%s_'}})
|
||||
def test_numref_with_prefix2(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -400,7 +400,7 @@ def test_numref_with_prefix2(app, status, warning):
|
||||
'\\nameref{\\detokenize{foo:foo}}}') in result
|
||||
|
||||
# sphinxmessages.sty
|
||||
result = (app.outdir / 'sphinxmessages.sty').read_text()
|
||||
result = (app.outdir / 'sphinxmessages.sty').read_text(encoding='utf8')
|
||||
print(result)
|
||||
assert r'\addto\captionsenglish{\renewcommand{\figurename}{Figure:}}' in result
|
||||
assert r'\def\fnum@figure{\figurename\thefigure{}.}' in result
|
||||
@@ -414,7 +414,7 @@ def test_numref_with_prefix2(app, status, warning):
|
||||
confoverrides={'numfig': True, 'language': 'ja'})
|
||||
def test_numref_with_language_ja(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -440,7 +440,7 @@ def test_numref_with_language_ja(app, status, warning):
|
||||
'\\nameref{\\detokenize{foo:foo}}}') in result
|
||||
|
||||
# sphinxmessages.sty
|
||||
result = (app.outdir / 'sphinxmessages.sty').read_text()
|
||||
result = (app.outdir / 'sphinxmessages.sty').read_text(encoding='utf8')
|
||||
print(result)
|
||||
assert '\\@iden{\\renewcommand{\\figurename}{図 }}' in result
|
||||
assert '\\@iden{\\renewcommand{\\tablename}{表 }}' in result
|
||||
@@ -451,10 +451,10 @@ def test_numref_with_language_ja(app, status, warning):
|
||||
def test_latex_obey_numfig_is_false(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
result = (app.outdir / 'SphinxManual.tex').read_text()
|
||||
result = (app.outdir / 'SphinxManual.tex').read_text(encoding='utf8')
|
||||
assert '\\usepackage{sphinx}' in result
|
||||
|
||||
result = (app.outdir / 'SphinxHowTo.tex').read_text()
|
||||
result = (app.outdir / 'SphinxHowTo.tex').read_text(encoding='utf8')
|
||||
assert '\\usepackage{sphinx}' in result
|
||||
|
||||
|
||||
@@ -464,10 +464,10 @@ def test_latex_obey_numfig_is_false(app, status, warning):
|
||||
def test_latex_obey_numfig_secnum_depth_is_zero(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
result = (app.outdir / 'SphinxManual.tex').read_text()
|
||||
result = (app.outdir / 'SphinxManual.tex').read_text(encoding='utf8')
|
||||
assert '\\usepackage[,nonumfigreset,mathnumfig]{sphinx}' in result
|
||||
|
||||
result = (app.outdir / 'SphinxHowTo.tex').read_text()
|
||||
result = (app.outdir / 'SphinxHowTo.tex').read_text(encoding='utf8')
|
||||
assert '\\usepackage[,nonumfigreset,mathnumfig]{sphinx}' in result
|
||||
|
||||
|
||||
@@ -477,10 +477,10 @@ def test_latex_obey_numfig_secnum_depth_is_zero(app, status, warning):
|
||||
def test_latex_obey_numfig_secnum_depth_is_two(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
result = (app.outdir / 'SphinxManual.tex').read_text()
|
||||
result = (app.outdir / 'SphinxManual.tex').read_text(encoding='utf8')
|
||||
assert '\\usepackage[,numfigreset=2,mathnumfig]{sphinx}' in result
|
||||
|
||||
result = (app.outdir / 'SphinxHowTo.tex').read_text()
|
||||
result = (app.outdir / 'SphinxHowTo.tex').read_text(encoding='utf8')
|
||||
assert '\\usepackage[,numfigreset=3,mathnumfig]{sphinx}' in result
|
||||
|
||||
|
||||
@@ -490,10 +490,10 @@ def test_latex_obey_numfig_secnum_depth_is_two(app, status, warning):
|
||||
def test_latex_obey_numfig_but_math_numfig_false(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
result = (app.outdir / 'SphinxManual.tex').read_text()
|
||||
result = (app.outdir / 'SphinxManual.tex').read_text(encoding='utf8')
|
||||
assert '\\usepackage[,numfigreset=1]{sphinx}' in result
|
||||
|
||||
result = (app.outdir / 'SphinxHowTo.tex').read_text()
|
||||
result = (app.outdir / 'SphinxHowTo.tex').read_text(encoding='utf8')
|
||||
assert '\\usepackage[,numfigreset=2]{sphinx}' in result
|
||||
|
||||
|
||||
@@ -502,7 +502,7 @@ def test_latex_add_latex_package(app, status, warning):
|
||||
app.add_latex_package('foo')
|
||||
app.add_latex_package('bar', 'baz')
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'test.tex').read_text()
|
||||
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
||||
assert '\\usepackage{foo}' in result
|
||||
assert '\\usepackage[baz]{bar}' in result
|
||||
|
||||
@@ -510,7 +510,7 @@ def test_latex_add_latex_package(app, status, warning):
|
||||
@pytest.mark.sphinx('latex', testroot='latex-babel')
|
||||
def test_babel_with_no_language_settings(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -523,7 +523,7 @@ def test_babel_with_no_language_settings(app, status, warning):
|
||||
assert '\\shorthandoff{"}' in result
|
||||
|
||||
# sphinxmessages.sty
|
||||
result = (app.outdir / 'sphinxmessages.sty').read_text()
|
||||
result = (app.outdir / 'sphinxmessages.sty').read_text(encoding='utf8')
|
||||
print(result)
|
||||
assert r'\def\pageautorefname{page}' in result
|
||||
assert r'\addto\captionsenglish{\renewcommand{\figurename}{Fig.\@{} }}' in result
|
||||
@@ -535,7 +535,7 @@ def test_babel_with_no_language_settings(app, status, warning):
|
||||
confoverrides={'language': 'de'})
|
||||
def test_babel_with_language_de(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -548,7 +548,7 @@ def test_babel_with_language_de(app, status, warning):
|
||||
assert '\\shorthandoff{"}' in result
|
||||
|
||||
# sphinxmessages.sty
|
||||
result = (app.outdir / 'sphinxmessages.sty').read_text()
|
||||
result = (app.outdir / 'sphinxmessages.sty').read_text(encoding='utf8')
|
||||
print(result)
|
||||
assert r'\def\pageautorefname{Seite}' in result
|
||||
assert r'\addto\captionsngerman{\renewcommand{\figurename}{Fig.\@{} }}' in result
|
||||
@@ -560,7 +560,7 @@ def test_babel_with_language_de(app, status, warning):
|
||||
confoverrides={'language': 'ru'})
|
||||
def test_babel_with_language_ru(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -573,7 +573,7 @@ def test_babel_with_language_ru(app, status, warning):
|
||||
assert '\\shorthandoff{"}' in result
|
||||
|
||||
# sphinxmessages.sty
|
||||
result = (app.outdir / 'sphinxmessages.sty').read_text()
|
||||
result = (app.outdir / 'sphinxmessages.sty').read_text(encoding='utf8')
|
||||
print(result)
|
||||
assert r'\def\pageautorefname{страница}' in result
|
||||
assert r'\addto\captionsrussian{\renewcommand{\figurename}{Fig.\@{} }}' in result
|
||||
@@ -585,7 +585,7 @@ def test_babel_with_language_ru(app, status, warning):
|
||||
confoverrides={'language': 'tr'})
|
||||
def test_babel_with_language_tr(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -598,7 +598,7 @@ def test_babel_with_language_tr(app, status, warning):
|
||||
assert '\\shorthandoff{=}' in result
|
||||
|
||||
# sphinxmessages.sty
|
||||
result = (app.outdir / 'sphinxmessages.sty').read_text()
|
||||
result = (app.outdir / 'sphinxmessages.sty').read_text(encoding='utf8')
|
||||
print(result)
|
||||
assert r'\def\pageautorefname{sayfa}' in result
|
||||
assert r'\addto\captionsturkish{\renewcommand{\figurename}{Fig.\@{} }}' in result
|
||||
@@ -610,7 +610,7 @@ def test_babel_with_language_tr(app, status, warning):
|
||||
confoverrides={'language': 'ja'})
|
||||
def test_babel_with_language_ja(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -622,7 +622,7 @@ def test_babel_with_language_ja(app, status, warning):
|
||||
assert '\\shorthandoff' not in result
|
||||
|
||||
# sphinxmessages.sty
|
||||
result = (app.outdir / 'sphinxmessages.sty').read_text()
|
||||
result = (app.outdir / 'sphinxmessages.sty').read_text(encoding='utf8')
|
||||
print(result)
|
||||
assert r'\def\pageautorefname{ページ}' in result
|
||||
assert '\\@iden{\\renewcommand{\\figurename}{Fig.\\@{} }}' in result
|
||||
@@ -634,7 +634,7 @@ def test_babel_with_language_ja(app, status, warning):
|
||||
confoverrides={'language': 'unknown'})
|
||||
def test_babel_with_unknown_language(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -649,7 +649,7 @@ def test_babel_with_unknown_language(app, status, warning):
|
||||
assert "WARNING: no Babel option known for language 'unknown'" in warning.getvalue()
|
||||
|
||||
# sphinxmessages.sty
|
||||
result = (app.outdir / 'sphinxmessages.sty').read_text()
|
||||
result = (app.outdir / 'sphinxmessages.sty').read_text(encoding='utf8')
|
||||
print(result)
|
||||
assert r'\def\pageautorefname{page}' in result
|
||||
assert r'\addto\captionsenglish{\renewcommand{\figurename}{Fig.\@{} }}' in result
|
||||
@@ -661,7 +661,7 @@ def test_babel_with_unknown_language(app, status, warning):
|
||||
confoverrides={'language': 'de', 'latex_engine': 'lualatex'})
|
||||
def test_polyglossia_with_language_de(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -675,7 +675,7 @@ def test_polyglossia_with_language_de(app, status, warning):
|
||||
assert '\\shorthandoff' not in result
|
||||
|
||||
# sphinxmessages.sty
|
||||
result = (app.outdir / 'sphinxmessages.sty').read_text()
|
||||
result = (app.outdir / 'sphinxmessages.sty').read_text(encoding='utf8')
|
||||
print(result)
|
||||
assert r'\def\pageautorefname{Seite}' in result
|
||||
assert r'\addto\captionsgerman{\renewcommand{\figurename}{Fig.\@{} }}' in result
|
||||
@@ -687,7 +687,7 @@ def test_polyglossia_with_language_de(app, status, warning):
|
||||
confoverrides={'language': 'de-1901', 'latex_engine': 'lualatex'})
|
||||
def test_polyglossia_with_language_de_1901(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -701,7 +701,7 @@ def test_polyglossia_with_language_de_1901(app, status, warning):
|
||||
assert '\\shorthandoff' not in result
|
||||
|
||||
# sphinxmessages.sty
|
||||
result = (app.outdir / 'sphinxmessages.sty').read_text()
|
||||
result = (app.outdir / 'sphinxmessages.sty').read_text(encoding='utf8')
|
||||
print(result)
|
||||
assert r'\def\pageautorefname{page}' in result
|
||||
assert r'\addto\captionsgerman{\renewcommand{\figurename}{Fig.\@{} }}' in result
|
||||
@@ -711,7 +711,7 @@ def test_polyglossia_with_language_de_1901(app, status, warning):
|
||||
@pytest.mark.sphinx('latex')
|
||||
def test_footnote(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'sphinxtests.tex').read_text()
|
||||
result = (app.outdir / 'sphinxtests.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -739,7 +739,7 @@ def test_footnote(app, status, warning):
|
||||
@pytest.mark.sphinx('latex', testroot='footnotes')
|
||||
def test_reference_in_caption_and_codeblock_in_footnote(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -778,7 +778,7 @@ def test_reference_in_caption_and_codeblock_in_footnote(app, status, warning):
|
||||
@pytest.mark.sphinx('latex', testroot='footnotes')
|
||||
def test_footnote_referred_multiple_times(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -800,7 +800,7 @@ def test_footnote_referred_multiple_times(app, status, warning):
|
||||
confoverrides={'latex_show_urls': 'inline'})
|
||||
def test_latex_show_urls_is_inline(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -857,7 +857,7 @@ def test_latex_show_urls_is_inline(app, status, warning):
|
||||
confoverrides={'latex_show_urls': 'footnote'})
|
||||
def test_latex_show_urls_is_footnote(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -919,7 +919,7 @@ def test_latex_show_urls_is_footnote(app, status, warning):
|
||||
confoverrides={'latex_show_urls': 'no'})
|
||||
def test_latex_show_urls_is_no(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -974,7 +974,7 @@ def test_latex_show_urls_footnote_and_substitutions(app, status, warning):
|
||||
@pytest.mark.sphinx('latex', testroot='image-in-section')
|
||||
def test_image_in_section(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -1000,7 +1000,7 @@ def test_latex_logo_if_not_found(app, status, warning):
|
||||
@pytest.mark.sphinx('latex', testroot='toctree-maxdepth')
|
||||
def test_toctree_maxdepth_manual(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -1017,7 +1017,7 @@ def test_toctree_maxdepth_manual(app, status, warning):
|
||||
]})
|
||||
def test_toctree_maxdepth_howto(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -1031,7 +1031,7 @@ def test_toctree_maxdepth_howto(app, status, warning):
|
||||
confoverrides={'root_doc': 'foo'})
|
||||
def test_toctree_not_found(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -1045,7 +1045,7 @@ def test_toctree_not_found(app, status, warning):
|
||||
confoverrides={'root_doc': 'bar'})
|
||||
def test_toctree_without_maxdepth(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -1058,7 +1058,7 @@ def test_toctree_without_maxdepth(app, status, warning):
|
||||
confoverrides={'root_doc': 'qux'})
|
||||
def test_toctree_with_deeper_maxdepth(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -1071,7 +1071,7 @@ def test_toctree_with_deeper_maxdepth(app, status, warning):
|
||||
confoverrides={'latex_toplevel_sectioning': None})
|
||||
def test_latex_toplevel_sectioning_is_None(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -1083,7 +1083,7 @@ def test_latex_toplevel_sectioning_is_None(app, status, warning):
|
||||
confoverrides={'latex_toplevel_sectioning': 'part'})
|
||||
def test_latex_toplevel_sectioning_is_part(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -1101,7 +1101,7 @@ def test_latex_toplevel_sectioning_is_part(app, status, warning):
|
||||
]})
|
||||
def test_latex_toplevel_sectioning_is_part_with_howto(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -1115,7 +1115,7 @@ def test_latex_toplevel_sectioning_is_part_with_howto(app, status, warning):
|
||||
confoverrides={'latex_toplevel_sectioning': 'chapter'})
|
||||
def test_latex_toplevel_sectioning_is_chapter(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -1131,7 +1131,7 @@ def test_latex_toplevel_sectioning_is_chapter(app, status, warning):
|
||||
]})
|
||||
def test_latex_toplevel_sectioning_is_chapter_with_howto(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -1143,7 +1143,7 @@ def test_latex_toplevel_sectioning_is_chapter_with_howto(app, status, warning):
|
||||
confoverrides={'latex_toplevel_sectioning': 'section'})
|
||||
def test_latex_toplevel_sectioning_is_section(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -1154,7 +1154,7 @@ def test_latex_toplevel_sectioning_is_section(app, status, warning):
|
||||
@pytest.mark.sphinx('latex', testroot='maxlistdepth')
|
||||
def test_maxlistdepth_at_ten(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
@@ -1165,7 +1165,7 @@ def test_maxlistdepth_at_ten(app, status, warning):
|
||||
@pytest.mark.test_params(shared_result='latex-table')
|
||||
def test_latex_table_tabulars(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
tables = {}
|
||||
for chap in re.split(r'\\(?:section|chapter){', result)[1:]:
|
||||
sectname, content = chap.split('}', 1)
|
||||
@@ -1173,7 +1173,7 @@ def test_latex_table_tabulars(app, status, warning):
|
||||
tables[sectname] = content.strip()
|
||||
|
||||
def get_expected(name):
|
||||
return (app.srcdir / 'expects' / (name + '.tex')).read_text().strip()
|
||||
return (app.srcdir / 'expects' / (name + '.tex')).read_text(encoding='utf8').strip()
|
||||
|
||||
# simple_table
|
||||
actual = tables['simple table']
|
||||
@@ -1235,7 +1235,7 @@ def test_latex_table_tabulars(app, status, warning):
|
||||
@pytest.mark.test_params(shared_result='latex-table')
|
||||
def test_latex_table_longtable(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
tables = {}
|
||||
for chap in re.split(r'\\(?:section|chapter){', result)[1:]:
|
||||
sectname, content = chap.split('}', 1)
|
||||
@@ -1243,7 +1243,7 @@ def test_latex_table_longtable(app, status, warning):
|
||||
tables[sectname] = content.strip()
|
||||
|
||||
def get_expected(name):
|
||||
return (app.srcdir / 'expects' / (name + '.tex')).read_text().strip()
|
||||
return (app.srcdir / 'expects' / (name + '.tex')).read_text(encoding='utf8').strip()
|
||||
|
||||
# longtable
|
||||
actual = tables['longtable']
|
||||
@@ -1295,14 +1295,14 @@ def test_latex_table_longtable(app, status, warning):
|
||||
@pytest.mark.test_params(shared_result='latex-table')
|
||||
def test_latex_table_complex_tables(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
tables = {}
|
||||
for chap in re.split(r'\\(?:section|renewcommand){', result)[1:]:
|
||||
sectname, content = chap.split('}', 1)
|
||||
tables[sectname] = content.strip()
|
||||
|
||||
def get_expected(name):
|
||||
return (app.srcdir / 'expects' / (name + '.tex')).read_text().strip()
|
||||
return (app.srcdir / 'expects' / (name + '.tex')).read_text(encoding='utf8').strip()
|
||||
|
||||
# grid table
|
||||
actual = tables['grid table']
|
||||
@@ -1319,7 +1319,7 @@ def test_latex_table_complex_tables(app, status, warning):
|
||||
confoverrides={'templates_path': ['_mytemplates/latex']})
|
||||
def test_latex_table_custom_template_caseA(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
assert 'SALUT LES COPAINS' in result
|
||||
|
||||
|
||||
@@ -1327,7 +1327,7 @@ def test_latex_table_custom_template_caseA(app, status, warning):
|
||||
confoverrides={'templates_path': ['_mytemplates']})
|
||||
def test_latex_table_custom_template_caseB(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
assert 'SALUT LES COPAINS' not in result
|
||||
|
||||
|
||||
@@ -1335,14 +1335,14 @@ def test_latex_table_custom_template_caseB(app, status, warning):
|
||||
@pytest.mark.test_params(shared_result='latex-table')
|
||||
def test_latex_table_custom_template_caseC(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
assert 'SALUT LES COPAINS' not in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='directives-raw')
|
||||
def test_latex_raw_directive(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
|
||||
# standard case
|
||||
assert 'standalone raw directive (HTML)' not in result
|
||||
@@ -1358,7 +1358,7 @@ def test_latex_raw_directive(app, status, warning):
|
||||
def test_latex_images(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
|
||||
# images are copied
|
||||
assert '\\sphinxincludegraphics{{python-logo}.png}' in result
|
||||
@@ -1382,7 +1382,7 @@ def test_latex_images(app, status, warning):
|
||||
def test_latex_index(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
assert ('A \\index{famous@\\spxentry{famous}}famous '
|
||||
'\\index{equation@\\spxentry{equation}}equation:\n' in result)
|
||||
assert ('\n\\index{Einstein@\\spxentry{Einstein}}'
|
||||
@@ -1396,8 +1396,8 @@ def test_latex_index(app, status, warning):
|
||||
def test_latex_equations(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
expected = (app.srcdir / 'expects' / 'latex-equations.tex').read_text().strip()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
expected = (app.srcdir / 'expects' / 'latex-equations.tex').read_text(encoding='utf8').strip()
|
||||
|
||||
assert expected in result
|
||||
|
||||
@@ -1406,7 +1406,7 @@ def test_latex_equations(app, status, warning):
|
||||
def test_latex_image_in_parsed_literal(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
assert ('{\\sphinxunactivateextrasandspace \\raisebox{-0.5\\height}'
|
||||
'{\\sphinxincludegraphics[height=2.00000cm]{{pic}.png}}'
|
||||
'}AFTER') in result
|
||||
@@ -1416,7 +1416,7 @@ def test_latex_image_in_parsed_literal(app, status, warning):
|
||||
def test_latex_nested_enumerated_list(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
assert ('\\sphinxsetlistlabels{\\arabic}{enumi}{enumii}{}{.}%\n'
|
||||
'\\setcounter{enumi}{4}\n' in result)
|
||||
assert ('\\sphinxsetlistlabels{\\alph}{enumii}{enumiii}{}{.}%\n'
|
||||
@@ -1433,7 +1433,7 @@ def test_latex_nested_enumerated_list(app, status, warning):
|
||||
def test_latex_thebibliography(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
assert ('\\begin{sphinxthebibliography}{AuthorYe}\n'
|
||||
'\\bibitem[AuthorYear]{index:authoryear}\n\\sphinxAtStartPar\n'
|
||||
@@ -1446,7 +1446,7 @@ def test_latex_thebibliography(app, status, warning):
|
||||
def test_latex_glossary(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
assert (r'\sphinxlineitem{ähnlich\index{ähnlich@\spxentry{ähnlich}|spxpagem}'
|
||||
r'\phantomsection'
|
||||
r'\label{\detokenize{index:term-ahnlich}}}' in result)
|
||||
@@ -1470,7 +1470,7 @@ def test_latex_glossary(app, status, warning):
|
||||
def test_latex_labels(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
|
||||
# figures
|
||||
assert (r'\caption{labeled figure}'
|
||||
@@ -1518,7 +1518,7 @@ def test_latex_labels(app, status, warning):
|
||||
@pytest.mark.sphinx('latex', testroot='latex-figure-in-admonition')
|
||||
def test_latex_figure_in_admonition(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
assert(r'\begin{figure}[H]' in result)
|
||||
|
||||
|
||||
@@ -1549,7 +1549,7 @@ def test_includegraphics_oversized(app, status, warning):
|
||||
@pytest.mark.sphinx('latex', testroot='index_on_title')
|
||||
def test_index_on_title(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
assert ('\\chapter{Test for index in top level title}\n'
|
||||
'\\label{\\detokenize{contents:test-for-index-in-top-level-title}}'
|
||||
'\\index{index@\\spxentry{index}}\n'
|
||||
@@ -1560,7 +1560,7 @@ def test_index_on_title(app, status, warning):
|
||||
confoverrides={'latex_engine': 'pdflatex'})
|
||||
def test_texescape_for_non_unicode_supported_engine(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
assert 'script small e: e' in result
|
||||
assert 'double struck italic small i: i' in result
|
||||
@@ -1572,7 +1572,7 @@ def test_texescape_for_non_unicode_supported_engine(app, status, warning):
|
||||
confoverrides={'latex_engine': 'xelatex'})
|
||||
def test_texescape_for_unicode_supported_engine(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
assert 'script small e: e' in result
|
||||
assert 'double struck italic small i: i' in result
|
||||
@@ -1584,7 +1584,7 @@ def test_texescape_for_unicode_supported_engine(app, status, warning):
|
||||
confoverrides={'latex_elements': {'extrapackages': r'\usepackage{foo}'}})
|
||||
def test_latex_elements_extrapackages(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'test.tex').read_text()
|
||||
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
||||
assert r'\usepackage{foo}' in result
|
||||
|
||||
|
||||
@@ -1597,6 +1597,6 @@ def test_latex_nested_tables(app, status, warning):
|
||||
@pytest.mark.sphinx('latex', testroot='latex-container')
|
||||
def test_latex_container(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
assert r'\begin{sphinxuseclass}{classname}' in result
|
||||
assert r'\end{sphinxuseclass}' in result
|
||||
|
||||
@@ -28,7 +28,7 @@ def test_defaults(app):
|
||||
app.build()
|
||||
|
||||
assert (app.outdir / 'output.txt').exists()
|
||||
content = (app.outdir / 'output.txt').read_text()
|
||||
content = (app.outdir / 'output.txt').read_text(encoding='utf8')
|
||||
|
||||
print(content)
|
||||
# looking for '#top' and '#does-not-exist' not found should fail
|
||||
@@ -49,7 +49,7 @@ def test_defaults_json(app):
|
||||
app.build()
|
||||
|
||||
assert (app.outdir / 'output.json').exists()
|
||||
content = (app.outdir / 'output.json').read_text()
|
||||
content = (app.outdir / 'output.json').read_text(encoding='utf8')
|
||||
print(content)
|
||||
|
||||
rows = [json.loads(x) for x in content.splitlines()]
|
||||
@@ -110,7 +110,7 @@ def test_anchors_ignored(app):
|
||||
app.build()
|
||||
|
||||
assert (app.outdir / 'output.txt').exists()
|
||||
content = (app.outdir / 'output.txt').read_text()
|
||||
content = (app.outdir / 'output.txt').read_text(encoding='utf8')
|
||||
|
||||
# expect all ok when excluding #top
|
||||
assert not content
|
||||
@@ -124,7 +124,7 @@ def test_raises_for_invalid_status(app):
|
||||
|
||||
with http_server(InternalServerErrorHandler):
|
||||
app.build()
|
||||
content = (app.outdir / 'output.txt').read_text()
|
||||
content = (app.outdir / 'output.txt').read_text(encoding='utf8')
|
||||
assert content == (
|
||||
"index.rst:1: [broken] http://localhost:7777/#anchor: "
|
||||
"500 Server Error: Internal Server Error "
|
||||
@@ -247,7 +247,7 @@ def test_follows_redirects_on_HEAD(app, capsys, warning):
|
||||
with http_server(make_redirect_handler(support_head=True)):
|
||||
app.build()
|
||||
stdout, stderr = capsys.readouterr()
|
||||
content = (app.outdir / 'output.txt').read_text()
|
||||
content = (app.outdir / 'output.txt').read_text(encoding='utf8')
|
||||
assert content == (
|
||||
"index.rst:1: [redirected with Found] "
|
||||
"http://localhost:7777/ to http://localhost:7777/?redirected=1\n"
|
||||
@@ -266,7 +266,7 @@ def test_follows_redirects_on_GET(app, capsys, warning):
|
||||
with http_server(make_redirect_handler(support_head=False)):
|
||||
app.build()
|
||||
stdout, stderr = capsys.readouterr()
|
||||
content = (app.outdir / 'output.txt').read_text()
|
||||
content = (app.outdir / 'output.txt').read_text(encoding='utf8')
|
||||
assert content == (
|
||||
"index.rst:1: [redirected with Found] "
|
||||
"http://localhost:7777/ to http://localhost:7777/?redirected=1\n"
|
||||
@@ -463,7 +463,7 @@ def test_too_many_requests_retry_after_int_delay(app, capsys, status):
|
||||
mock.patch("sphinx.builders.linkcheck.DEFAULT_DELAY", 0), \
|
||||
mock.patch("sphinx.builders.linkcheck.QUEUE_POLL_SECS", 0.01):
|
||||
app.build()
|
||||
content = (app.outdir / 'output.json').read_text()
|
||||
content = (app.outdir / 'output.json').read_text(encoding='utf8')
|
||||
assert json.loads(content) == {
|
||||
"filename": "index.rst",
|
||||
"lineno": 1,
|
||||
@@ -489,7 +489,7 @@ def test_too_many_requests_retry_after_HTTP_date(app, capsys):
|
||||
retry_after = wsgiref.handlers.format_date_time(time.mktime(now))
|
||||
with http_server(make_retry_after_handler([(429, retry_after), (200, None)])):
|
||||
app.build()
|
||||
content = (app.outdir / 'output.json').read_text()
|
||||
content = (app.outdir / 'output.json').read_text(encoding='utf8')
|
||||
assert json.loads(content) == {
|
||||
"filename": "index.rst",
|
||||
"lineno": 1,
|
||||
@@ -512,7 +512,7 @@ def test_too_many_requests_retry_after_without_header(app, capsys):
|
||||
with http_server(make_retry_after_handler([(429, None), (200, None)])),\
|
||||
mock.patch("sphinx.builders.linkcheck.DEFAULT_DELAY", 0):
|
||||
app.build()
|
||||
content = (app.outdir / 'output.json').read_text()
|
||||
content = (app.outdir / 'output.json').read_text(encoding='utf8')
|
||||
assert json.loads(content) == {
|
||||
"filename": "index.rst",
|
||||
"lineno": 1,
|
||||
@@ -535,7 +535,7 @@ def test_too_many_requests_user_timeout(app, capsys):
|
||||
app.config.linkcheck_rate_limit_timeout = 0.0
|
||||
with http_server(make_retry_after_handler([(429, None)])):
|
||||
app.build()
|
||||
content = (app.outdir / 'output.json').read_text()
|
||||
content = (app.outdir / 'output.json').read_text(encoding='utf8')
|
||||
assert json.loads(content) == {
|
||||
"filename": "index.rst",
|
||||
"lineno": 1,
|
||||
@@ -606,9 +606,9 @@ class ConnectionResetHandler(http.server.BaseHTTPRequestHandler):
|
||||
def test_get_after_head_raises_connection_error(app):
|
||||
with http_server(ConnectionResetHandler):
|
||||
app.build()
|
||||
content = (app.outdir / 'output.txt').read_text()
|
||||
content = (app.outdir / 'output.txt').read_text(encoding='utf8')
|
||||
assert not content
|
||||
content = (app.outdir / 'output.json').read_text()
|
||||
content = (app.outdir / 'output.json').read_text(encoding='utf8')
|
||||
assert json.loads(content) == {
|
||||
"filename": "index.rst",
|
||||
"lineno": 1,
|
||||
|
||||
@@ -11,7 +11,7 @@ def test_all(app, status, warning):
|
||||
app.builder.build_all()
|
||||
assert (app.outdir / 'sphinxtests.1').exists()
|
||||
|
||||
content = (app.outdir / 'sphinxtests.1').read_text()
|
||||
content = (app.outdir / 'sphinxtests.1').read_text(encoding='utf8')
|
||||
assert r'\fBprint \fP\fIi\fP\fB\en\fP' in content
|
||||
assert r'\fBmanpage\en\fP' in content
|
||||
|
||||
@@ -35,7 +35,7 @@ def test_all(app, status, warning):
|
||||
def test_man_pages_empty_description(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'title.1').read_text()
|
||||
content = (app.outdir / 'title.1').read_text(encoding='utf8')
|
||||
assert r'title \-' not in content
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ def test_man_make_section_directory(app, status, warning):
|
||||
@pytest.mark.sphinx('man', testroot='directive-code')
|
||||
def test_captioned_code_block(app, status, warning):
|
||||
app.builder.build_all()
|
||||
content = (app.outdir / 'python.1').read_text()
|
||||
content = (app.outdir / 'python.1').read_text(encoding='utf8')
|
||||
|
||||
assert ('.sp\n'
|
||||
'caption \\fItest\\fP rb\n'
|
||||
@@ -80,5 +80,5 @@ def test_default_man_pages():
|
||||
@pytest.mark.sphinx('man', testroot='markup-rubric')
|
||||
def test_rubric(app, status, warning):
|
||||
app.build()
|
||||
content = (app.outdir / 'python.1').read_text()
|
||||
content = (app.outdir / 'python.1').read_text(encoding='utf8')
|
||||
assert 'This is a rubric\n' in content
|
||||
|
||||
@@ -41,7 +41,7 @@ def test_texinfo_warnings(app, status, warning):
|
||||
def test_texinfo(app, status, warning):
|
||||
TexinfoTranslator.ignore_missing_images = True
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'sphinxtests.texi').read_text()
|
||||
result = (app.outdir / 'sphinxtests.texi').read_text(encoding='utf8')
|
||||
assert ('@anchor{markup doc}@anchor{11}'
|
||||
'@anchor{markup id1}@anchor{12}'
|
||||
'@anchor{markup testing-various-markup}@anchor{13}' in result)
|
||||
@@ -62,7 +62,7 @@ def test_texinfo(app, status, warning):
|
||||
def test_texinfo_rubric(app, status, warning):
|
||||
app.build()
|
||||
|
||||
output = (app.outdir / 'python.texi').read_text()
|
||||
output = (app.outdir / 'python.texi').read_text(encoding='utf8')
|
||||
assert '@heading This is a rubric' in output
|
||||
assert '@heading This is a multiline rubric' in output
|
||||
|
||||
@@ -71,7 +71,7 @@ def test_texinfo_rubric(app, status, warning):
|
||||
def test_texinfo_citation(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
output = (app.outdir / 'python.texi').read_text()
|
||||
output = (app.outdir / 'python.texi').read_text(encoding='utf8')
|
||||
assert 'This is a citation ref; @ref{1,,[CITE1]} and @ref{2,,[CITE2]}.' in output
|
||||
assert ('@anchor{index cite1}@anchor{1}@w{(CITE1)} \n'
|
||||
'This is a citation\n') in output
|
||||
@@ -110,20 +110,20 @@ def test_texinfo_escape_id(app, status, warning):
|
||||
def test_texinfo_footnote(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
output = (app.outdir / 'python.texi').read_text()
|
||||
output = (app.outdir / 'python.texi').read_text(encoding='utf8')
|
||||
assert 'First footnote: @footnote{\nFirst\n}' in output
|
||||
|
||||
|
||||
@pytest.mark.sphinx('texinfo')
|
||||
def test_texinfo_xrefs(app, status, warning):
|
||||
app.builder.build_all()
|
||||
output = (app.outdir / 'sphinxtests.texi').read_text()
|
||||
output = (app.outdir / 'sphinxtests.texi').read_text(encoding='utf8')
|
||||
assert re.search(r'@ref{\w+,,--plugin\.option}', output)
|
||||
|
||||
# Now rebuild it without xrefs
|
||||
app.config.texinfo_cross_references = False
|
||||
app.builder.build_all()
|
||||
output = (app.outdir / 'sphinxtests.texi').read_text()
|
||||
output = (app.outdir / 'sphinxtests.texi').read_text(encoding='utf8')
|
||||
assert not re.search(r'@ref{\w+,,--plugin\.option}', output)
|
||||
assert 'Link to perl +p, --ObjC++, --plugin.option, create-auth-token, arg and -j' in output
|
||||
|
||||
@@ -132,7 +132,7 @@ def test_texinfo_xrefs(app, status, warning):
|
||||
def test_texinfo_samp_with_variable(app, status, warning):
|
||||
app.build()
|
||||
|
||||
output = (app.outdir / 'sphinxtests.texi').read_text()
|
||||
output = (app.outdir / 'sphinxtests.texi').read_text(encoding='utf8')
|
||||
|
||||
assert '@code{@var{variable_only}}' in output
|
||||
assert '@code{@var{variable} and text}' in output
|
||||
|
||||
@@ -18,7 +18,7 @@ def with_text_app(*args, **kw):
|
||||
@with_text_app()
|
||||
def test_maxwitdh_with_prefix(app, status, warning):
|
||||
app.builder.build_update()
|
||||
result = (app.outdir / 'maxwidth.txt').read_text()
|
||||
result = (app.outdir / 'maxwidth.txt').read_text(encoding='utf8')
|
||||
|
||||
lines = result.splitlines()
|
||||
line_widths = [column_width(line) for line in lines]
|
||||
@@ -41,7 +41,7 @@ def test_maxwitdh_with_prefix(app, status, warning):
|
||||
def test_lineblock(app, status, warning):
|
||||
# regression test for #1109: need empty line after line block
|
||||
app.builder.build_update()
|
||||
result = (app.outdir / 'lineblock.txt').read_text()
|
||||
result = (app.outdir / 'lineblock.txt').read_text(encoding='utf8')
|
||||
expect = (
|
||||
"* one\n"
|
||||
"\n"
|
||||
@@ -56,7 +56,7 @@ def test_lineblock(app, status, warning):
|
||||
@with_text_app()
|
||||
def test_nonascii_title_line(app, status, warning):
|
||||
app.builder.build_update()
|
||||
result = (app.outdir / 'nonascii_title.txt').read_text()
|
||||
result = (app.outdir / 'nonascii_title.txt').read_text(encoding='utf8')
|
||||
expect_underline = '*********'
|
||||
result_underline = result.splitlines()[1].strip()
|
||||
assert expect_underline == result_underline
|
||||
@@ -65,7 +65,7 @@ def test_nonascii_title_line(app, status, warning):
|
||||
@with_text_app()
|
||||
def test_nonascii_table(app, status, warning):
|
||||
app.builder.build_update()
|
||||
result = (app.outdir / 'nonascii_table.txt').read_text()
|
||||
result = (app.outdir / 'nonascii_table.txt').read_text(encoding='utf8')
|
||||
lines = [line.strip() for line in result.splitlines() if line.strip()]
|
||||
line_widths = [column_width(line) for line in lines]
|
||||
assert len(set(line_widths)) == 1 # same widths
|
||||
@@ -74,7 +74,7 @@ def test_nonascii_table(app, status, warning):
|
||||
@with_text_app()
|
||||
def test_nonascii_maxwidth(app, status, warning):
|
||||
app.builder.build_update()
|
||||
result = (app.outdir / 'nonascii_maxwidth.txt').read_text()
|
||||
result = (app.outdir / 'nonascii_maxwidth.txt').read_text(encoding='utf8')
|
||||
lines = [line.strip() for line in result.splitlines() if line.strip()]
|
||||
line_widths = [column_width(line) for line in lines]
|
||||
assert max(line_widths) < MAXWIDTH
|
||||
@@ -118,7 +118,7 @@ def test_table_cell():
|
||||
@with_text_app()
|
||||
def test_table_with_empty_cell(app, status, warning):
|
||||
app.builder.build_update()
|
||||
result = (app.outdir / 'table.txt').read_text()
|
||||
result = (app.outdir / 'table.txt').read_text(encoding='utf8')
|
||||
lines = [line.strip() for line in result.splitlines() if line.strip()]
|
||||
assert lines[0] == "+-------+-------+"
|
||||
assert lines[1] == "| XXX | XXX |"
|
||||
@@ -132,7 +132,7 @@ def test_table_with_empty_cell(app, status, warning):
|
||||
@with_text_app()
|
||||
def test_table_with_rowspan(app, status, warning):
|
||||
app.builder.build_update()
|
||||
result = (app.outdir / 'table_rowspan.txt').read_text()
|
||||
result = (app.outdir / 'table_rowspan.txt').read_text(encoding='utf8')
|
||||
lines = [line.strip() for line in result.splitlines() if line.strip()]
|
||||
assert lines[0] == "+-------+-------+"
|
||||
assert lines[1] == "| XXXXXXXXX |"
|
||||
@@ -146,7 +146,7 @@ def test_table_with_rowspan(app, status, warning):
|
||||
@with_text_app()
|
||||
def test_table_with_colspan(app, status, warning):
|
||||
app.builder.build_update()
|
||||
result = (app.outdir / 'table_colspan.txt').read_text()
|
||||
result = (app.outdir / 'table_colspan.txt').read_text(encoding='utf8')
|
||||
lines = [line.strip() for line in result.splitlines() if line.strip()]
|
||||
assert lines[0] == "+-------+-------+"
|
||||
assert lines[1] == "| XXX | XXX |"
|
||||
@@ -160,7 +160,7 @@ def test_table_with_colspan(app, status, warning):
|
||||
@with_text_app()
|
||||
def test_table_with_colspan_left(app, status, warning):
|
||||
app.builder.build_update()
|
||||
result = (app.outdir / 'table_colspan_left.txt').read_text()
|
||||
result = (app.outdir / 'table_colspan_left.txt').read_text(encoding='utf8')
|
||||
lines = [line.strip() for line in result.splitlines() if line.strip()]
|
||||
assert lines[0] == "+-------+-------+"
|
||||
assert lines[1] == "| XXX | XXX |"
|
||||
@@ -174,7 +174,7 @@ def test_table_with_colspan_left(app, status, warning):
|
||||
@with_text_app()
|
||||
def test_table_with_colspan_and_rowspan(app, status, warning):
|
||||
app.builder.build_update()
|
||||
result = (app.outdir / 'table_colspan_and_rowspan.txt').read_text()
|
||||
result = (app.outdir / 'table_colspan_and_rowspan.txt').read_text(encoding='utf8')
|
||||
lines = [line.strip() for line in result.splitlines() if line.strip()]
|
||||
assert result
|
||||
assert lines[0] == "+-------+-------+-------+"
|
||||
@@ -189,7 +189,7 @@ def test_table_with_colspan_and_rowspan(app, status, warning):
|
||||
@with_text_app()
|
||||
def test_list_items_in_admonition(app, status, warning):
|
||||
app.builder.build_update()
|
||||
result = (app.outdir / 'listitems.txt').read_text()
|
||||
result = (app.outdir / 'listitems.txt').read_text(encoding='utf8')
|
||||
lines = [line.rstrip() for line in result.splitlines()]
|
||||
assert lines[0] == "See also:"
|
||||
assert lines[1] == ""
|
||||
@@ -201,7 +201,7 @@ def test_list_items_in_admonition(app, status, warning):
|
||||
@with_text_app()
|
||||
def test_secnums(app, status, warning):
|
||||
app.builder.build_all()
|
||||
index = (app.outdir / 'index.txt').read_text()
|
||||
index = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
lines = index.splitlines()
|
||||
assert lines[0] == "* 1. Section A"
|
||||
assert lines[1] == ""
|
||||
@@ -210,7 +210,7 @@ def test_secnums(app, status, warning):
|
||||
assert lines[4] == " * 2.1. Sub Ba"
|
||||
assert lines[5] == ""
|
||||
assert lines[6] == " * 2.2. Sub Bb"
|
||||
doc2 = (app.outdir / 'doc2.txt').read_text()
|
||||
doc2 = (app.outdir / 'doc2.txt').read_text(encoding='utf8')
|
||||
expect = (
|
||||
"2. Section B\n"
|
||||
"************\n"
|
||||
@@ -227,7 +227,7 @@ def test_secnums(app, status, warning):
|
||||
|
||||
app.config.text_secnumber_suffix = " "
|
||||
app.builder.build_all()
|
||||
index = (app.outdir / 'index.txt').read_text()
|
||||
index = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
lines = index.splitlines()
|
||||
assert lines[0] == "* 1 Section A"
|
||||
assert lines[1] == ""
|
||||
@@ -236,7 +236,7 @@ def test_secnums(app, status, warning):
|
||||
assert lines[4] == " * 2.1 Sub Ba"
|
||||
assert lines[5] == ""
|
||||
assert lines[6] == " * 2.2 Sub Bb"
|
||||
doc2 = (app.outdir / 'doc2.txt').read_text()
|
||||
doc2 = (app.outdir / 'doc2.txt').read_text(encoding='utf8')
|
||||
expect = (
|
||||
"2 Section B\n"
|
||||
"***********\n"
|
||||
@@ -253,7 +253,7 @@ def test_secnums(app, status, warning):
|
||||
|
||||
app.config.text_add_secnumbers = False
|
||||
app.builder.build_all()
|
||||
index = (app.outdir / 'index.txt').read_text()
|
||||
index = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
lines = index.splitlines()
|
||||
assert lines[0] == "* Section A"
|
||||
assert lines[1] == ""
|
||||
@@ -262,7 +262,7 @@ def test_secnums(app, status, warning):
|
||||
assert lines[4] == " * Sub Ba"
|
||||
assert lines[5] == ""
|
||||
assert lines[6] == " * Sub Bb"
|
||||
doc2 = (app.outdir / 'doc2.txt').read_text()
|
||||
doc2 = (app.outdir / 'doc2.txt').read_text(encoding='utf8')
|
||||
expect = (
|
||||
"Section B\n"
|
||||
"*********\n"
|
||||
|
||||
@@ -24,5 +24,5 @@ def expect_date(request, monkeypatch):
|
||||
@pytest.mark.sphinx('html', testroot='correct-year')
|
||||
def test_correct_year(expect_date, app):
|
||||
app.build()
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert expect_date in content
|
||||
|
||||
@@ -28,7 +28,7 @@ def test_LiteralIncludeReader(literal_inc_path):
|
||||
options = {'lineno-match': True}
|
||||
reader = LiteralIncludeReader(literal_inc_path, options, DUMMY_CONFIG)
|
||||
content, lines = reader.read()
|
||||
assert content == literal_inc_path.read_text()
|
||||
assert content == literal_inc_path.read_text(encoding='utf8')
|
||||
assert lines == 13
|
||||
assert reader.lineno_start == 1
|
||||
|
||||
@@ -38,7 +38,7 @@ def test_LiteralIncludeReader_lineno_start(literal_inc_path):
|
||||
options = {'lineno-start': 4}
|
||||
reader = LiteralIncludeReader(literal_inc_path, options, DUMMY_CONFIG)
|
||||
content, lines = reader.read()
|
||||
assert content == literal_inc_path.read_text()
|
||||
assert content == literal_inc_path.read_text(encoding='utf8')
|
||||
assert lines == 13
|
||||
assert reader.lineno_start == 4
|
||||
|
||||
@@ -337,7 +337,7 @@ def test_force_option(app, status, warning):
|
||||
@pytest.mark.sphinx('html', testroot='directive-code')
|
||||
def test_code_block_caption_html(app, status, warning):
|
||||
app.builder.build(['caption'])
|
||||
html = (app.outdir / 'caption.html').read_text()
|
||||
html = (app.outdir / 'caption.html').read_text(encoding='utf8')
|
||||
caption = ('<div class="code-block-caption">'
|
||||
'<span class="caption-number">Listing 1 </span>'
|
||||
'<span class="caption-text">caption <em>test</em> rb'
|
||||
@@ -349,7 +349,7 @@ def test_code_block_caption_html(app, status, warning):
|
||||
@pytest.mark.sphinx('latex', testroot='directive-code')
|
||||
def test_code_block_caption_latex(app, status, warning):
|
||||
app.builder.build_all()
|
||||
latex = (app.outdir / 'python.tex').read_text()
|
||||
latex = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
caption = '\\sphinxSetupCaptionForVerbatim{caption \\sphinxstyleemphasis{test} rb}'
|
||||
label = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:id1}}}'
|
||||
link = '\\hyperref[\\detokenize{caption:name-test-rb}]' \
|
||||
@@ -362,7 +362,7 @@ def test_code_block_caption_latex(app, status, warning):
|
||||
@pytest.mark.sphinx('latex', testroot='directive-code')
|
||||
def test_code_block_namedlink_latex(app, status, warning):
|
||||
app.builder.build_all()
|
||||
latex = (app.outdir / 'python.tex').read_text()
|
||||
latex = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
label1 = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:name-test-rb}}}'
|
||||
link1 = '\\hyperref[\\detokenize{caption:name-test-rb}]'\
|
||||
'{\\sphinxcrossref{\\DUrole{std,std-ref}{Ruby}}'
|
||||
@@ -379,7 +379,7 @@ def test_code_block_namedlink_latex(app, status, warning):
|
||||
@pytest.mark.sphinx('latex', testroot='directive-code')
|
||||
def test_code_block_emphasize_latex(app, status, warning):
|
||||
app.builder.build(['emphasize'])
|
||||
latex = (app.outdir / 'python.tex').read_text().replace('\r\n', '\n')
|
||||
latex = (app.outdir / 'python.tex').read_text(encoding='utf8').replace('\r\n', '\n')
|
||||
includes = '\\fvset{hllines={, 5, 6, 13, 14, 15, 24, 25, 26,}}%\n'
|
||||
assert includes in latex
|
||||
includes = '\\end{sphinxVerbatim}\n\\sphinxresetverbatimhllines\n'
|
||||
@@ -392,7 +392,7 @@ def test_literal_include(app, status, warning):
|
||||
et = etree_parse(app.outdir / 'index.xml')
|
||||
secs = et.findall('./section/section')
|
||||
literal_include = secs[1].findall('literal_block')
|
||||
literal_src = (app.srcdir / 'literal.inc').read_text()
|
||||
literal_src = (app.srcdir / 'literal.inc').read_text(encoding='utf8')
|
||||
assert len(literal_include) > 0
|
||||
actual = literal_include[0].text
|
||||
assert actual == literal_src
|
||||
@@ -425,7 +425,7 @@ def test_literal_include_block_start_with_comment_or_brank(app, status, warning)
|
||||
@pytest.mark.sphinx('html', testroot='directive-code')
|
||||
def test_literal_include_linenos(app, status, warning):
|
||||
app.builder.build(['linenos'])
|
||||
html = (app.outdir / 'linenos.html').read_text()
|
||||
html = (app.outdir / 'linenos.html').read_text(encoding='utf8')
|
||||
|
||||
# :linenos:
|
||||
assert ('<span class="linenos"> 1</span><span class="c1">'
|
||||
@@ -443,7 +443,7 @@ def test_literal_include_linenos(app, status, warning):
|
||||
@pytest.mark.sphinx('latex', testroot='directive-code')
|
||||
def test_literalinclude_file_whole_of_emptyline(app, status, warning):
|
||||
app.builder.build_all()
|
||||
latex = (app.outdir / 'python.tex').read_text().replace('\r\n', '\n')
|
||||
latex = (app.outdir / 'python.tex').read_text(encoding='utf8').replace('\r\n', '\n')
|
||||
includes = (
|
||||
'\\begin{sphinxVerbatim}'
|
||||
'[commandchars=\\\\\\{\\},numbers=left,firstnumber=1,stepnumber=1]\n'
|
||||
@@ -457,7 +457,7 @@ def test_literalinclude_file_whole_of_emptyline(app, status, warning):
|
||||
@pytest.mark.sphinx('html', testroot='directive-code')
|
||||
def test_literalinclude_caption_html(app, status, warning):
|
||||
app.builder.build('index')
|
||||
html = (app.outdir / 'caption.html').read_text()
|
||||
html = (app.outdir / 'caption.html').read_text(encoding='utf8')
|
||||
caption = ('<div class="code-block-caption">'
|
||||
'<span class="caption-number">Listing 2 </span>'
|
||||
'<span class="caption-text">caption <strong>test</strong> py'
|
||||
@@ -469,7 +469,7 @@ def test_literalinclude_caption_html(app, status, warning):
|
||||
@pytest.mark.sphinx('latex', testroot='directive-code')
|
||||
def test_literalinclude_caption_latex(app, status, warning):
|
||||
app.builder.build('index')
|
||||
latex = (app.outdir / 'python.tex').read_text()
|
||||
latex = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
caption = '\\sphinxSetupCaptionForVerbatim{caption \\sphinxstylestrong{test} py}'
|
||||
label = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:id2}}}'
|
||||
link = '\\hyperref[\\detokenize{caption:name-test-py}]' \
|
||||
@@ -482,7 +482,7 @@ def test_literalinclude_caption_latex(app, status, warning):
|
||||
@pytest.mark.sphinx('latex', testroot='directive-code')
|
||||
def test_literalinclude_namedlink_latex(app, status, warning):
|
||||
app.builder.build('index')
|
||||
latex = (app.outdir / 'python.tex').read_text()
|
||||
latex = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
label1 = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:name-test-py}}}'
|
||||
link1 = '\\hyperref[\\detokenize{caption:name-test-py}]'\
|
||||
'{\\sphinxcrossref{\\DUrole{std,std-ref}{Python}}'
|
||||
@@ -569,7 +569,7 @@ def test_code_block_highlighted(app, status, warning):
|
||||
@pytest.mark.sphinx('html', testroot='directive-code')
|
||||
def test_linenothreshold(app, status, warning):
|
||||
app.builder.build(['linenothreshold'])
|
||||
html = (app.outdir / 'linenothreshold.html').read_text()
|
||||
html = (app.outdir / 'linenothreshold.html').read_text(encoding='utf8')
|
||||
|
||||
# code-block using linenothreshold
|
||||
assert ('<span class="linenos">1</span><span class="k">class</span> '
|
||||
|
||||
@@ -616,7 +616,7 @@ def filter_warnings(warning, file):
|
||||
|
||||
|
||||
def extract_role_links(app, filename):
|
||||
t = (app.outdir / filename).read_text()
|
||||
t = (app.outdir / filename).read_text(encoding='utf8')
|
||||
lis = [l for l in t.split('\n') if l.startswith("<li")]
|
||||
entries = []
|
||||
for l in lis:
|
||||
@@ -646,7 +646,7 @@ def test_domain_c_build_namespace(app, status, warning):
|
||||
app.builder.build_all()
|
||||
ws = filter_warnings(warning, "namespace")
|
||||
assert len(ws) == 0
|
||||
t = (app.outdir / "namespace.html").read_text()
|
||||
t = (app.outdir / "namespace.html").read_text(encoding='utf8')
|
||||
for id_ in ('NS.NSVar', 'NULLVar', 'ZeroVar', 'NS2.NS3.NS2NS3Var', 'PopVar'):
|
||||
assert 'id="c.{}"'.format(id_) in t
|
||||
|
||||
|
||||
@@ -1157,14 +1157,14 @@ def test_domain_cpp_build_with_add_function_parentheses_is_True(app, status, war
|
||||
]
|
||||
|
||||
f = 'roles.html'
|
||||
t = (app.outdir / f).read_text()
|
||||
t = (app.outdir / f).read_text(encoding='utf8')
|
||||
for s in rolePatterns:
|
||||
check(s, t, f)
|
||||
for s in parenPatterns:
|
||||
check(s, t, f)
|
||||
|
||||
f = 'any-role.html'
|
||||
t = (app.outdir / f).read_text()
|
||||
t = (app.outdir / f).read_text(encoding='utf8')
|
||||
for s in parenPatterns:
|
||||
check(s, t, f)
|
||||
|
||||
@@ -1198,14 +1198,14 @@ def test_domain_cpp_build_with_add_function_parentheses_is_False(app, status, wa
|
||||
]
|
||||
|
||||
f = 'roles.html'
|
||||
t = (app.outdir / f).read_text()
|
||||
t = (app.outdir / f).read_text(encoding='utf8')
|
||||
for s in rolePatterns:
|
||||
check(s, t, f)
|
||||
for s in parenPatterns:
|
||||
check(s, t, f)
|
||||
|
||||
f = 'any-role.html'
|
||||
t = (app.outdir / f).read_text()
|
||||
t = (app.outdir / f).read_text(encoding='utf8')
|
||||
for s in parenPatterns:
|
||||
check(s, t, f)
|
||||
|
||||
@@ -1215,7 +1215,7 @@ def test_domain_cpp_build_xref_consistency(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
test = 'xref_consistency.html'
|
||||
output = (app.outdir / test).read_text()
|
||||
output = (app.outdir / test).read_text(encoding='utf8')
|
||||
|
||||
def classes(role, tag):
|
||||
pattern = (r'{role}-role:.*?'
|
||||
|
||||
@@ -131,7 +131,7 @@ def test_domain_py_xrefs(app, status, warning):
|
||||
def test_domain_py_xrefs_abbreviations(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'abbr.html').read_text()
|
||||
content = (app.outdir / 'abbr.html').read_text(encoding='utf8')
|
||||
assert re.search(r'normal: <a .* href="module.html#module_a.submodule.ModTopLevel.'
|
||||
r'mod_child_1" .*><.*>module_a.submodule.ModTopLevel.mod_child_1\(\)'
|
||||
r'<.*></a>',
|
||||
@@ -186,7 +186,7 @@ def test_domain_py_objects(app, status, warning):
|
||||
def test_resolve_xref_for_properties(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'module.html').read_text()
|
||||
content = (app.outdir / 'module.html').read_text(encoding='utf8')
|
||||
assert ('Link to <a class="reference internal" href="#module_a.submodule.ModTopLevel.prop"'
|
||||
' title="module_a.submodule.ModTopLevel.prop">'
|
||||
'<code class="xref py py-attr docutils literal notranslate"><span class="pre">'
|
||||
@@ -234,7 +234,7 @@ def test_domain_py_find_obj(app, status, warning):
|
||||
def test_domain_py_canonical(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'canonical.html').read_text()
|
||||
content = (app.outdir / 'canonical.html').read_text(encoding='utf8')
|
||||
assert ('<a class="reference internal" href="#canonical.Foo" title="canonical.Foo">'
|
||||
'<code class="xref py py-class docutils literal notranslate">'
|
||||
'<span class="pre">Foo</span></code></a>' in content)
|
||||
@@ -1315,7 +1315,7 @@ def test_noindexentry(app):
|
||||
@pytest.mark.sphinx('html', testroot='domain-py-python_use_unqualified_type_names')
|
||||
def test_python_python_use_unqualified_type_names(app, status, warning):
|
||||
app.build()
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert ('<span class="n"><a class="reference internal" href="#foo.Name" title="foo.Name">'
|
||||
'<span class="pre">Name</span></a></span>' in content)
|
||||
assert '<span class="n"><span class="pre">foo.Age</span></span>' in content
|
||||
@@ -1328,7 +1328,7 @@ def test_python_python_use_unqualified_type_names(app, status, warning):
|
||||
confoverrides={'python_use_unqualified_type_names': False})
|
||||
def test_python_python_use_unqualified_type_names_disabled(app, status, warning):
|
||||
app.build()
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert ('<span class="n"><a class="reference internal" href="#foo.Name" title="foo.Name">'
|
||||
'<span class="pre">foo.Name</span></a></span>' in content)
|
||||
assert '<span class="n"><span class="pre">foo.Age</span></span>' in content
|
||||
|
||||
@@ -408,7 +408,7 @@ def test_productionlist(app, status, warning):
|
||||
('SecondLine', 'firstLineRule.html#grammar-token-SecondLine', 'SecondLine'),
|
||||
]
|
||||
|
||||
text = (app.outdir / 'LineContinuation.html').read_text()
|
||||
text = (app.outdir / 'LineContinuation.html').read_text(encoding='utf8')
|
||||
assert "A</strong> ::= B C D E F G" in text
|
||||
|
||||
|
||||
|
||||
@@ -275,7 +275,7 @@ def test_multibyte_parameters(make_app, apidoc):
|
||||
assert (outdir / 'conf.py').isfile()
|
||||
assert (outdir / 'index.rst').isfile()
|
||||
|
||||
conf_py = (outdir / 'conf.py').read_text()
|
||||
conf_py = (outdir / 'conf.py').read_text(encoding='utf8')
|
||||
assert "project = 'プロジェクト名'" in conf_py
|
||||
assert "author = '著者名'" in conf_py
|
||||
assert "version = 'バージョン'" in conf_py
|
||||
@@ -408,13 +408,13 @@ def test_private(tempdir):
|
||||
# without --private option
|
||||
apidoc_main(['-o', tempdir, tempdir])
|
||||
assert (tempdir / 'hello.rst').exists()
|
||||
assert ':private-members:' not in (tempdir / 'hello.rst').read_text()
|
||||
assert ':private-members:' not in (tempdir / 'hello.rst').read_text(encoding='utf8')
|
||||
assert not (tempdir / '_world.rst').exists()
|
||||
|
||||
# with --private option
|
||||
apidoc_main(['--private', '-f', '-o', tempdir, tempdir])
|
||||
assert (tempdir / 'hello.rst').exists()
|
||||
assert ':private-members:' in (tempdir / 'hello.rst').read_text()
|
||||
assert ':private-members:' in (tempdir / 'hello.rst').read_text(encoding='utf8')
|
||||
assert (tempdir / '_world.rst').exists()
|
||||
|
||||
|
||||
@@ -426,7 +426,7 @@ def test_toc_file(tempdir):
|
||||
apidoc_main(['-o', tempdir, tempdir])
|
||||
assert (outdir / 'modules.rst').exists()
|
||||
|
||||
content = (outdir / 'modules.rst').read_text()
|
||||
content = (outdir / 'modules.rst').read_text(encoding='utf8')
|
||||
assert content == ("test_toc_file0\n"
|
||||
"==============\n"
|
||||
"\n"
|
||||
@@ -442,7 +442,7 @@ def test_module_file(tempdir):
|
||||
apidoc_main(['-o', tempdir, tempdir])
|
||||
assert (outdir / 'example.rst').exists()
|
||||
|
||||
content = (outdir / 'example.rst').read_text()
|
||||
content = (outdir / 'example.rst').read_text(encoding='utf8')
|
||||
assert content == ("example module\n"
|
||||
"==============\n"
|
||||
"\n"
|
||||
@@ -458,7 +458,7 @@ def test_module_file_noheadings(tempdir):
|
||||
apidoc_main(['--no-headings', '-o', tempdir, tempdir])
|
||||
assert (outdir / 'example.rst').exists()
|
||||
|
||||
content = (outdir / 'example.rst').read_text()
|
||||
content = (outdir / 'example.rst').read_text(encoding='utf8')
|
||||
assert content == (".. automodule:: example\n"
|
||||
" :members:\n"
|
||||
" :undoc-members:\n"
|
||||
@@ -477,7 +477,7 @@ def test_package_file(tempdir):
|
||||
assert (outdir / 'testpkg.rst').exists()
|
||||
assert (outdir / 'testpkg.subpkg.rst').exists()
|
||||
|
||||
content = (outdir / 'testpkg.rst').read_text()
|
||||
content = (outdir / 'testpkg.rst').read_text(encoding='utf8')
|
||||
assert content == ("testpkg package\n"
|
||||
"===============\n"
|
||||
"\n"
|
||||
@@ -516,7 +516,7 @@ def test_package_file(tempdir):
|
||||
" :undoc-members:\n"
|
||||
" :show-inheritance:\n")
|
||||
|
||||
content = (outdir / 'testpkg.subpkg.rst').read_text()
|
||||
content = (outdir / 'testpkg.subpkg.rst').read_text(encoding='utf8')
|
||||
assert content == ("testpkg.subpkg package\n"
|
||||
"======================\n"
|
||||
"\n"
|
||||
@@ -538,7 +538,7 @@ def test_package_file_separate(tempdir):
|
||||
assert (outdir / 'testpkg.rst').exists()
|
||||
assert (outdir / 'testpkg.example.rst').exists()
|
||||
|
||||
content = (outdir / 'testpkg.rst').read_text()
|
||||
content = (outdir / 'testpkg.rst').read_text(encoding='utf8')
|
||||
assert content == ("testpkg package\n"
|
||||
"===============\n"
|
||||
"\n"
|
||||
@@ -558,7 +558,7 @@ def test_package_file_separate(tempdir):
|
||||
" :undoc-members:\n"
|
||||
" :show-inheritance:\n")
|
||||
|
||||
content = (outdir / 'testpkg.example.rst').read_text()
|
||||
content = (outdir / 'testpkg.example.rst').read_text(encoding='utf8')
|
||||
assert content == ("testpkg.example module\n"
|
||||
"======================\n"
|
||||
"\n"
|
||||
@@ -575,7 +575,7 @@ def test_package_file_module_first(tempdir):
|
||||
(outdir / 'testpkg' / 'example.py').write_text('')
|
||||
apidoc_main(['--module-first', '-o', tempdir, tempdir])
|
||||
|
||||
content = (outdir / 'testpkg.rst').read_text()
|
||||
content = (outdir / 'testpkg.rst').read_text(encoding='utf8')
|
||||
assert content == ("testpkg package\n"
|
||||
"===============\n"
|
||||
"\n"
|
||||
@@ -603,7 +603,7 @@ def test_package_file_without_submodules(tempdir):
|
||||
apidoc_main(['-o', tempdir, tempdir / 'testpkg'])
|
||||
assert (outdir / 'testpkg.rst').exists()
|
||||
|
||||
content = (outdir / 'testpkg.rst').read_text()
|
||||
content = (outdir / 'testpkg.rst').read_text(encoding='utf8')
|
||||
assert content == ("testpkg package\n"
|
||||
"===============\n"
|
||||
"\n"
|
||||
@@ -623,7 +623,7 @@ def test_namespace_package_file(tempdir):
|
||||
apidoc_main(['--implicit-namespace', '-o', tempdir, tempdir / 'testpkg'])
|
||||
assert (outdir / 'testpkg.rst').exists()
|
||||
|
||||
content = (outdir / 'testpkg.rst').read_text()
|
||||
content = (outdir / 'testpkg.rst').read_text(encoding='utf8')
|
||||
assert content == ("testpkg namespace\n"
|
||||
"=================\n"
|
||||
"\n"
|
||||
|
||||
@@ -819,7 +819,7 @@ def test_autodoc_typehints_none_for_overload(app):
|
||||
confoverrides={'autodoc_typehints': "description"})
|
||||
def test_autodoc_typehints_description(app):
|
||||
app.build()
|
||||
context = (app.outdir / 'index.txt').read_text()
|
||||
context = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
assert ('target.typehints.incr(a, b=1)\n'
|
||||
'\n'
|
||||
' Parameters:\n'
|
||||
@@ -868,7 +868,7 @@ def test_autodoc_typehints_description_no_undoc(app):
|
||||
' :return: another tuple\n'
|
||||
)
|
||||
app.build()
|
||||
context = (app.outdir / 'index.txt').read_text()
|
||||
context = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
assert ('target.typehints.incr(a, b=1)\n'
|
||||
'\n'
|
||||
'target.typehints.decr(a, b=1)\n'
|
||||
@@ -920,7 +920,7 @@ def test_autodoc_typehints_description_no_undoc_doc_rtype(app):
|
||||
' :return: nothing\n'
|
||||
)
|
||||
app.build()
|
||||
context = (app.outdir / 'index.txt').read_text()
|
||||
context = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
assert ('target.typehints.incr(a, b=1)\n'
|
||||
'\n'
|
||||
' Return type:\n'
|
||||
@@ -964,7 +964,7 @@ def test_autodoc_typehints_description_with_documented_init(app):
|
||||
' :special-members: __init__\n'
|
||||
)
|
||||
app.build()
|
||||
context = (app.outdir / 'index.txt').read_text()
|
||||
context = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
assert ('class target.typehints._ClassWithDocumentedInit(x)\n'
|
||||
'\n'
|
||||
' Class docstring.\n'
|
||||
@@ -995,7 +995,7 @@ def test_autodoc_typehints_description_with_documented_init_no_undoc(app):
|
||||
' :special-members: __init__\n'
|
||||
)
|
||||
app.build()
|
||||
context = (app.outdir / 'index.txt').read_text()
|
||||
context = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
assert ('class target.typehints._ClassWithDocumentedInit(x)\n'
|
||||
'\n'
|
||||
' Class docstring.\n'
|
||||
@@ -1020,7 +1020,7 @@ def test_autodoc_typehints_description_with_documented_init_no_undoc_doc_rtype(a
|
||||
' :special-members: __init__\n'
|
||||
)
|
||||
app.build()
|
||||
context = (app.outdir / 'index.txt').read_text()
|
||||
context = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
assert ('class target.typehints._ClassWithDocumentedInit(x)\n'
|
||||
'\n'
|
||||
' Class docstring.\n'
|
||||
@@ -1051,7 +1051,7 @@ def test_autodoc_typehints_both(app):
|
||||
'.. autofunction:: target.overload.sum\n'
|
||||
)
|
||||
app.build()
|
||||
context = (app.outdir / 'index.txt').read_text()
|
||||
context = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
assert ('target.typehints.incr(a: int, b: int = 1) -> int\n'
|
||||
'\n'
|
||||
' Parameters:\n'
|
||||
@@ -1219,7 +1219,7 @@ def test_autodoc_type_aliases(app):
|
||||
def test_autodoc_typehints_description_and_type_aliases(app):
|
||||
(app.srcdir / 'autodoc_type_aliases.rst').write_text('.. autofunction:: target.autodoc_type_aliases.sum')
|
||||
app.build()
|
||||
context = (app.outdir / 'autodoc_type_aliases.txt').read_text()
|
||||
context = (app.outdir / 'autodoc_type_aliases.txt').read_text(encoding='utf8')
|
||||
assert ('target.autodoc_type_aliases.sum(x, y)\n'
|
||||
'\n'
|
||||
' docstring\n'
|
||||
|
||||
@@ -9,7 +9,7 @@ import pytest
|
||||
def test_autosectionlabel_html(app, status, warning, skipped_labels=False):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
html = ('<li><p><a class="reference internal" href="#introduce-of-sphinx">'
|
||||
'<span class=".*?">Introduce of Sphinx</span></a></p></li>')
|
||||
assert re.search(html, content, re.S)
|
||||
@@ -53,7 +53,7 @@ def test_autosectionlabel_prefix_document_html(app, status, warning):
|
||||
def test_autosectionlabel_maxdepth(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
||||
# depth: 1
|
||||
html = ('<li><p><a class="reference internal" href="#test-ext-autosectionlabel">'
|
||||
|
||||
@@ -332,7 +332,7 @@ def test_autosummary_generate(app, status, warning):
|
||||
assert doctree[3][0][0][2][4].astext() == 'autosummary_dummy_module.bar(x[, y])\n\n'
|
||||
assert doctree[3][0][0][2][5].astext() == 'autosummary_dummy_module.qux\n\na module-level attribute'
|
||||
|
||||
module = (app.srcdir / 'generated' / 'autosummary_dummy_module.rst').read_text()
|
||||
module = (app.srcdir / 'generated' / 'autosummary_dummy_module.rst').read_text(encoding='utf8')
|
||||
|
||||
assert (' .. autosummary::\n'
|
||||
' \n'
|
||||
@@ -345,7 +345,7 @@ def test_autosummary_generate(app, status, warning):
|
||||
' quuz\n'
|
||||
' \n' in module)
|
||||
|
||||
Foo = (app.srcdir / 'generated' / 'autosummary_dummy_module.Foo.rst').read_text()
|
||||
Foo = (app.srcdir / 'generated' / 'autosummary_dummy_module.Foo.rst').read_text(encoding='utf8')
|
||||
assert '.. automethod:: __init__' in Foo
|
||||
assert (' .. autosummary::\n'
|
||||
' \n'
|
||||
@@ -360,17 +360,17 @@ def test_autosummary_generate(app, status, warning):
|
||||
' ~Foo.value\n'
|
||||
' \n' in Foo)
|
||||
|
||||
FooBar = (app.srcdir / 'generated' / 'autosummary_dummy_module.Foo.Bar.rst').read_text()
|
||||
FooBar = (app.srcdir / 'generated' / 'autosummary_dummy_module.Foo.Bar.rst').read_text(encoding='utf8')
|
||||
assert ('.. currentmodule:: autosummary_dummy_module\n'
|
||||
'\n'
|
||||
'.. autoclass:: Foo.Bar\n' in FooBar)
|
||||
|
||||
Foo_value = (app.srcdir / 'generated' / 'autosummary_dummy_module.Foo.value.rst').read_text()
|
||||
Foo_value = (app.srcdir / 'generated' / 'autosummary_dummy_module.Foo.value.rst').read_text(encoding='utf8')
|
||||
assert ('.. currentmodule:: autosummary_dummy_module\n'
|
||||
'\n'
|
||||
'.. autoattribute:: Foo.value' in Foo_value)
|
||||
|
||||
qux = (app.srcdir / 'generated' / 'autosummary_dummy_module.qux.rst').read_text()
|
||||
qux = (app.srcdir / 'generated' / 'autosummary_dummy_module.qux.rst').read_text(encoding='utf8')
|
||||
assert ('.. currentmodule:: autosummary_dummy_module\n'
|
||||
'\n'
|
||||
'.. autodata:: qux' in qux)
|
||||
@@ -386,7 +386,7 @@ def test_autosummary_generate_overwrite1(app_params, make_app):
|
||||
(srcdir / 'generated' / 'autosummary_dummy_module.rst').write_text('')
|
||||
|
||||
app = make_app(*args, **kwargs)
|
||||
content = (srcdir / 'generated' / 'autosummary_dummy_module.rst').read_text()
|
||||
content = (srcdir / 'generated' / 'autosummary_dummy_module.rst').read_text(encoding='utf8')
|
||||
assert content == ''
|
||||
assert 'autosummary_dummy_module.rst' not in app._warning.getvalue()
|
||||
|
||||
@@ -401,7 +401,7 @@ def test_autosummary_generate_overwrite2(app_params, make_app):
|
||||
(srcdir / 'generated' / 'autosummary_dummy_module.rst').write_text('')
|
||||
|
||||
app = make_app(*args, **kwargs)
|
||||
content = (srcdir / 'generated' / 'autosummary_dummy_module.rst').read_text()
|
||||
content = (srcdir / 'generated' / 'autosummary_dummy_module.rst').read_text(encoding='utf8')
|
||||
assert content != ''
|
||||
assert 'autosummary_dummy_module.rst' not in app._warning.getvalue()
|
||||
|
||||
@@ -425,12 +425,12 @@ def test_autosummary_recursive(app, status, warning):
|
||||
assert (app.srcdir / 'generated' / 'package2.module.rst').exists() is False
|
||||
|
||||
# Check content of recursively generated stub-files
|
||||
content = (app.srcdir / 'generated' / 'package.rst').read_text()
|
||||
content = (app.srcdir / 'generated' / 'package.rst').read_text(encoding='utf8')
|
||||
assert 'package.module' in content
|
||||
assert 'package.package' in content
|
||||
assert 'package.module_importfail' in content
|
||||
|
||||
content = (app.srcdir / 'generated' / 'package.package.rst').read_text()
|
||||
content = (app.srcdir / 'generated' / 'package.package.rst').read_text(encoding='utf8')
|
||||
assert 'package.package.module' in content
|
||||
|
||||
|
||||
@@ -465,7 +465,7 @@ def test_autosummary_filename_map(app, status, warning):
|
||||
@pytest.mark.sphinx('latex', **default_kw)
|
||||
def test_autosummary_latex_table_colspec(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
assert r'\begin{longtable}[c]{\X{1}{2}\X{1}{2}}' in result
|
||||
@@ -515,7 +515,7 @@ def test_autosummary_imported_members(app, status, warning):
|
||||
# generated/foo is generated successfully
|
||||
assert app.env.get_doctree('generated/autosummary_dummy_package')
|
||||
|
||||
module = (app.srcdir / 'generated' / 'autosummary_dummy_package.rst').read_text()
|
||||
module = (app.srcdir / 'generated' / 'autosummary_dummy_package.rst').read_text(encoding='utf8')
|
||||
assert (' .. autosummary::\n'
|
||||
' \n'
|
||||
' Bar\n'
|
||||
@@ -535,7 +535,7 @@ def test_generate_autosummary_docs_property(app):
|
||||
mock.return_value = [AutosummaryEntry('target.methods.Base.prop', 'prop', None, False)]
|
||||
generate_autosummary_docs([], output_dir=app.srcdir, app=app)
|
||||
|
||||
content = (app.srcdir / 'target.methods.Base.prop.rst').read_text()
|
||||
content = (app.srcdir / 'target.methods.Base.prop.rst').read_text(encoding='utf8')
|
||||
assert content == ("target.methods.Base.prop\n"
|
||||
"========================\n"
|
||||
"\n"
|
||||
@@ -548,7 +548,7 @@ def test_generate_autosummary_docs_property(app):
|
||||
def test_autosummary_skip_member(app):
|
||||
app.build()
|
||||
|
||||
content = (app.srcdir / 'generate' / 'target.Foo.rst').read_text()
|
||||
content = (app.srcdir / 'generate' / 'target.Foo.rst').read_text(encoding='utf8')
|
||||
assert 'Foo.skipmeth' not in content
|
||||
assert 'Foo._privatemeth' in content
|
||||
|
||||
@@ -557,7 +557,7 @@ def test_autosummary_skip_member(app):
|
||||
def test_autosummary_template(app):
|
||||
app.build()
|
||||
|
||||
content = (app.srcdir / 'generate' / 'target.Foo.rst').read_text()
|
||||
content = (app.srcdir / 'generate' / 'target.Foo.rst').read_text(encoding='utf8')
|
||||
assert 'EMPTY' in content
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import pytest
|
||||
def test_build(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
py_undoc = (app.outdir / 'python.txt').read_text()
|
||||
py_undoc = (app.outdir / 'python.txt').read_text(encoding='utf8')
|
||||
assert py_undoc.startswith('Undocumented Python objects\n'
|
||||
'===========================\n')
|
||||
assert 'autodoc_target\n--------------\n' in py_undoc
|
||||
@@ -22,7 +22,7 @@ def test_build(app, status, warning):
|
||||
|
||||
assert "undocumented py" not in status.getvalue()
|
||||
|
||||
c_undoc = (app.outdir / 'c.txt').read_text()
|
||||
c_undoc = (app.outdir / 'c.txt').read_text(encoding='utf8')
|
||||
assert c_undoc.startswith('Undocumented C API elements\n'
|
||||
'===========================\n')
|
||||
assert 'api.h' in c_undoc
|
||||
@@ -46,7 +46,7 @@ def test_build(app, status, warning):
|
||||
@pytest.mark.sphinx('coverage', testroot='ext-coverage')
|
||||
def test_coverage_ignore_pyobjects(app, status, warning):
|
||||
app.builder.build_all()
|
||||
actual = (app.outdir / 'python.txt').read_text()
|
||||
actual = (app.outdir / 'python.txt').read_text(encoding='utf8')
|
||||
expected = '''Undocumented Python objects
|
||||
===========================
|
||||
coverage_not_ignored
|
||||
|
||||
@@ -23,4 +23,4 @@ def test_no_cname_for_github_io_domain(app, status, warning):
|
||||
def test_cname_for_custom_domain(app, status, warning):
|
||||
app.builder.build_all()
|
||||
assert (app.outdir / '.nojekyll').exists()
|
||||
assert (app.outdir / 'CNAME').read_text() == 'sphinx-doc.org'
|
||||
assert (app.outdir / 'CNAME').read_text(encoding='utf8') == 'sphinx-doc.org'
|
||||
|
||||
@@ -13,7 +13,7 @@ from sphinx.ext.graphviz import ClickableMapDefinition
|
||||
def test_graphviz_png_html(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
if docutils.__version_info__ < (0, 17):
|
||||
html = (r'<div class="figure align-default" .*?>\s*'
|
||||
r'<div class="graphviz"><img .*?/></div>\s*<p class="caption">'
|
||||
@@ -56,7 +56,7 @@ def test_graphviz_png_html(app, status, warning):
|
||||
def test_graphviz_svg_html(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
||||
if docutils.__version_info__ < (0, 17):
|
||||
html = (r'<div class=\"figure align-default\" .*?>\n'
|
||||
@@ -118,7 +118,7 @@ def test_graphviz_svg_html(app, status, warning):
|
||||
def test_graphviz_latex(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'python.tex').read_text()
|
||||
content = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
macro = ('\\\\begin{figure}\\[htbp\\]\n\\\\centering\n\\\\capstart\n\n'
|
||||
'\\\\sphinxincludegraphics\\[\\]{graphviz-\\w+.pdf}\n'
|
||||
'\\\\caption{caption of graph}\\\\label{.*}\\\\end{figure}')
|
||||
@@ -144,7 +144,7 @@ def test_graphviz_latex(app, status, warning):
|
||||
def test_graphviz_i18n(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
html = '<img src=".*?" alt="digraph {\n BAR -> BAZ\n}" class="graphviz" />'
|
||||
assert re.search(html, content, re.M)
|
||||
|
||||
|
||||
@@ -6,6 +6,6 @@ import pytest
|
||||
@pytest.mark.sphinx('text', testroot='ext-ifconfig')
|
||||
def test_ifconfig(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'index.txt').read_text()
|
||||
result = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
assert 'spam' in result
|
||||
assert 'ham' not in result
|
||||
|
||||
@@ -10,7 +10,7 @@ import pytest
|
||||
def test_ext_imgconverter(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'python.tex').read_text()
|
||||
content = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
|
||||
# supported image (not converted)
|
||||
assert '\\sphinxincludegraphics{{img}.pdf}' in content
|
||||
|
||||
@@ -138,7 +138,7 @@ def test_inheritance_diagram(app, status, warning):
|
||||
def test_inheritance_diagram_png_html(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
||||
if docutils.__version_info__ < (0, 17):
|
||||
pattern = ('<div class="figure align-default" id="id1">\n'
|
||||
@@ -163,7 +163,7 @@ def test_inheritance_diagram_png_html(app, status, warning):
|
||||
def test_inheritance_diagram_svg_html(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
||||
if docutils.__version_info__ < (0, 17):
|
||||
pattern = ('<div class="figure align-default" id="id1">\n'
|
||||
@@ -192,7 +192,7 @@ def test_inheritance_diagram_svg_html(app, status, warning):
|
||||
def test_inheritance_diagram_latex(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'python.tex').read_text()
|
||||
content = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
|
||||
pattern = ('\\\\begin{figure}\\[htbp]\n\\\\centering\n\\\\capstart\n\n'
|
||||
'\\\\sphinxincludegraphics\\[\\]{inheritance-\\w+.pdf}\n'
|
||||
@@ -214,7 +214,7 @@ def test_inheritance_diagram_latex_alias(app, status, warning):
|
||||
assert ('test.Bar', 'test.Bar', ['alias.Foo'], None) in aliased_graph
|
||||
assert ('alias.Foo', 'alias.Foo', [], None) in aliased_graph
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
||||
if docutils.__version_info__ < (0, 17):
|
||||
pattern = ('<div class="figure align-default" id="id1">\n'
|
||||
|
||||
@@ -246,7 +246,7 @@ def test_missing_reference_cppdomain(tempdir, app, status, warning):
|
||||
load_mappings(app)
|
||||
|
||||
app.build()
|
||||
html = (app.outdir / 'index.html').read_text()
|
||||
html = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert ('<a class="reference external"'
|
||||
' href="https://docs.python.org/index.html#cpp_foo_bar"'
|
||||
' title="(in foo v2.0)">'
|
||||
@@ -533,7 +533,7 @@ def test_intersphinx_role(app, warning):
|
||||
load_mappings(app)
|
||||
|
||||
app.build()
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
wStr = warning.getvalue()
|
||||
|
||||
html = '<a class="reference external" href="http://example.org/{}" title="(in foo v2.0)">'
|
||||
|
||||
@@ -32,7 +32,7 @@ def test_imgmath_png(app, status, warning):
|
||||
if "dvipng command 'dvipng' cannot be run" in warning.getvalue():
|
||||
raise pytest.skip.Exception('dvipng command "dvipng" is not available')
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
html = (r'<div class="math">\s*<p>\s*<img src="_images/math/\w+.png"'
|
||||
r'\s*alt="a\^2\+b\^2=c\^2"/>\s*</p>\s*</div>')
|
||||
assert re.search(html, content, re.S)
|
||||
@@ -50,7 +50,7 @@ def test_imgmath_svg(app, status, warning):
|
||||
if "dvisvgm command 'dvisvgm' cannot be run" in warning.getvalue():
|
||||
raise pytest.skip.Exception('dvisvgm command "dvisvgm" is not available')
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
html = (r'<div class="math">\s*<p>\s*<img src="_images/math/\w+.svg"'
|
||||
r'\s*alt="a\^2\+b\^2=c\^2"/>\s*</p>\s*</div>')
|
||||
assert re.search(html, content, re.S)
|
||||
@@ -62,7 +62,7 @@ def test_imgmath_svg(app, status, warning):
|
||||
def test_mathjax_options(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert ('<script async="async" integrity="sha384-0123456789" '
|
||||
'src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js">'
|
||||
'</script>' in content)
|
||||
@@ -73,7 +73,7 @@ def test_mathjax_options(app, status, warning):
|
||||
def test_mathjax_align(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
html = (r'<div class="math notranslate nohighlight">\s*'
|
||||
r'\\\[ \\begin\{align\}\\begin\{aligned\}S \&= \\pi r\^2\\\\'
|
||||
r'V \&= \\frac\{4\}\{3\} \\pi r\^3\\end\{aligned\}\\end\{align\} \\\]</div>')
|
||||
@@ -86,7 +86,7 @@ def test_mathjax_align(app, status, warning):
|
||||
def test_math_number_all_mathjax(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
html = (r'<div class="math notranslate nohighlight" id="equation-index-0">\s*'
|
||||
r'<span class="eqno">\(1\)<a .*>\xb6</a></span>\\\[a\^2\+b\^2=c\^2\\\]</div>')
|
||||
assert re.search(html, content, re.S)
|
||||
@@ -97,7 +97,7 @@ def test_math_number_all_mathjax(app, status, warning):
|
||||
def test_math_number_all_latex(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'python.tex').read_text()
|
||||
content = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
macro = (r'\\begin{equation\*}\s*'
|
||||
r'\\begin{split}a\^2\+b\^2=c\^2\\end{split}\s*'
|
||||
r'\\end{equation\*}')
|
||||
@@ -127,7 +127,7 @@ def test_math_number_all_latex(app, status, warning):
|
||||
def test_math_eqref_format_html(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'math.html').read_text()
|
||||
content = (app.outdir / 'math.html').read_text(encoding='utf8')
|
||||
html = ('<p>Referencing equation <a class="reference internal" '
|
||||
'href="#equation-foo">Eq.1</a> and <a class="reference internal" '
|
||||
'href="#equation-foo">Eq.1</a>.</p>')
|
||||
@@ -140,7 +140,7 @@ def test_math_eqref_format_html(app, status, warning):
|
||||
def test_math_eqref_format_latex(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'python.tex').read_text()
|
||||
content = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
macro = (r'Referencing equation Eq.\\ref{equation:math:foo} and '
|
||||
r'Eq.\\ref{equation:math:foo}.')
|
||||
assert re.search(macro, content, re.S)
|
||||
@@ -153,7 +153,7 @@ def test_math_eqref_format_latex(app, status, warning):
|
||||
def test_mathjax_numfig_html(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'math.html').read_text()
|
||||
content = (app.outdir / 'math.html').read_text(encoding='utf8')
|
||||
html = ('<div class="math notranslate nohighlight" id="equation-math-0">\n'
|
||||
'<span class="eqno">(1.2)')
|
||||
assert html in content
|
||||
@@ -171,7 +171,7 @@ def test_mathjax_numfig_html(app, status, warning):
|
||||
def test_imgmath_numfig_html(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'page.html').read_text()
|
||||
content = (app.outdir / 'page.html').read_text(encoding='utf8')
|
||||
html = '<span class="eqno">(3)<a class="headerlink" href="#equation-bar"'
|
||||
assert html in content
|
||||
html = ('<p>Referencing equations <a class="reference internal" '
|
||||
@@ -211,7 +211,7 @@ def test_math_compat(app, status, warning):
|
||||
def test_mathjax3_config(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert MATHJAX_URL in content
|
||||
assert ('<script defer="defer" src="%s">' % MATHJAX_URL in content)
|
||||
assert ('<script>window.MathJax = {"extensions": ["tex2jax.js"]}</script>' in content)
|
||||
@@ -223,7 +223,7 @@ def test_mathjax3_config(app, status, warning):
|
||||
def test_mathjax2_config(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert ('<script async="async" src="%s">' % MATHJAX_URL in content)
|
||||
assert ('<script type="text/x-mathjax-config">'
|
||||
'MathJax.Hub.Config({"extensions": ["tex2jax.js"]})'
|
||||
@@ -237,7 +237,7 @@ def test_mathjax2_config(app, status, warning):
|
||||
def test_mathjax_options_async_for_mathjax3(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert MATHJAX_URL in content
|
||||
assert ('<script async="async" src="%s">' % MATHJAX_URL in content)
|
||||
|
||||
@@ -249,7 +249,7 @@ def test_mathjax_options_async_for_mathjax3(app, status, warning):
|
||||
def test_mathjax_options_defer_for_mathjax2(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert ('<script defer="defer" src="%s">' % MATHJAX_URL in content)
|
||||
|
||||
|
||||
@@ -258,10 +258,10 @@ def test_mathjax_options_defer_for_mathjax2(app, status, warning):
|
||||
def test_mathjax_is_installed_only_if_document_having_math(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert MATHJAX_URL in content
|
||||
|
||||
content = (app.outdir / 'nomath.html').read_text()
|
||||
content = (app.outdir / 'nomath.html').read_text(encoding='utf8')
|
||||
assert MATHJAX_URL not in content
|
||||
|
||||
|
||||
@@ -270,7 +270,7 @@ def test_mathjax_is_installed_only_if_document_having_math(app, status, warning)
|
||||
def test_mathjax_is_not_installed_if_no_equations(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert 'MathJax.js' not in content
|
||||
|
||||
|
||||
@@ -280,8 +280,8 @@ def test_mathjax_is_installed_if_no_equations_when_forced(app, status, warning):
|
||||
app.set_html_assets_policy('always')
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert MATHJAX_URL in content
|
||||
|
||||
content = (app.outdir / 'nomath.html').read_text()
|
||||
content = (app.outdir / 'nomath.html').read_text(encoding='utf8')
|
||||
assert MATHJAX_URL in content
|
||||
|
||||
@@ -17,7 +17,7 @@ def test_todo(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
# check todolist
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert ('<p class="admonition-title">Todo</p>\n'
|
||||
'<p>todo in foo</p>') in content
|
||||
|
||||
@@ -25,7 +25,7 @@ def test_todo(app, status, warning):
|
||||
'<p>todo in bar</p>') in content
|
||||
|
||||
# check todo
|
||||
content = (app.outdir / 'foo.html').read_text()
|
||||
content = (app.outdir / 'foo.html').read_text(encoding='utf8')
|
||||
assert ('<p class="admonition-title">Todo</p>\n'
|
||||
'<p>todo in foo</p>') in content
|
||||
|
||||
@@ -55,7 +55,7 @@ def test_todo_not_included(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
# check todolist
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert ('<p class="admonition-title">Todo</p>\n'
|
||||
'<p>todo in foo</p>') not in content
|
||||
|
||||
@@ -63,7 +63,7 @@ def test_todo_not_included(app, status, warning):
|
||||
'<p>todo in bar</p>') not in content
|
||||
|
||||
# check todo
|
||||
content = (app.outdir / 'foo.html').read_text()
|
||||
content = (app.outdir / 'foo.html').read_text(encoding='utf8')
|
||||
assert ('<p class="admonition-title">Todo</p>\n'
|
||||
'<p>todo in foo</p>') not in content
|
||||
|
||||
@@ -90,7 +90,7 @@ def test_todo_valid_link(app, status, warning):
|
||||
# Ensure the LaTeX output is built.
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'python.tex').read_text()
|
||||
content = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
|
||||
# Look for the link to foo. Note that there are two of them because the
|
||||
# source document uses todolist twice. We could equally well look for links
|
||||
|
||||
@@ -16,7 +16,7 @@ def test_viewcode(app, status, warning):
|
||||
warnings
|
||||
)
|
||||
|
||||
result = (app.outdir / 'index.html').read_text()
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert result.count('href="_modules/spam/mod1.html#func1"') == 2
|
||||
assert result.count('href="_modules/spam/mod2.html#func2"') == 2
|
||||
assert result.count('href="_modules/spam/mod1.html#Class1"') == 2
|
||||
@@ -29,7 +29,7 @@ def test_viewcode(app, status, warning):
|
||||
# the next assert fails, until the autodoc bug gets fixed
|
||||
assert result.count('this is the class attribute class_attr') == 2
|
||||
|
||||
result = (app.outdir / '_modules/spam/mod1.html').read_text()
|
||||
result = (app.outdir / '_modules/spam/mod1.html').read_text(encoding='utf8')
|
||||
result = re.sub('<span class=".*?">', '<span>', result) # filter pygments classes
|
||||
assert ('<div class="viewcode-block" id="Class1"><a class="viewcode-back" '
|
||||
'href="../../index.html#spam.Class1">[docs]</a>'
|
||||
@@ -47,7 +47,7 @@ def test_viewcode_epub_default(app, status, warning):
|
||||
|
||||
assert not (app.outdir / '_modules/spam/mod1.xhtml').exists()
|
||||
|
||||
result = (app.outdir / 'index.xhtml').read_text()
|
||||
result = (app.outdir / 'index.xhtml').read_text(encoding='utf8')
|
||||
assert result.count('href="_modules/spam/mod1.xhtml#func1"') == 0
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ def test_viewcode_epub_enabled(app, status, warning):
|
||||
|
||||
assert (app.outdir / '_modules/spam/mod1.xhtml').exists()
|
||||
|
||||
result = (app.outdir / 'index.xhtml').read_text()
|
||||
result = (app.outdir / 'index.xhtml').read_text(encoding='utf8')
|
||||
assert result.count('href="_modules/spam/mod1.xhtml#func1"') == 2
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ def test_viewcode_epub_enabled(app, status, warning):
|
||||
def test_linkcode(app, status, warning):
|
||||
app.builder.build(['objects'])
|
||||
|
||||
stuff = (app.outdir / 'objects.html').read_text()
|
||||
stuff = (app.outdir / 'objects.html').read_text(encoding='utf8')
|
||||
|
||||
assert 'http://foobar/source/foolib.py' in stuff
|
||||
assert 'http://foobar/js/' in stuff
|
||||
@@ -78,7 +78,7 @@ def test_linkcode(app, status, warning):
|
||||
def test_local_source_files(app, status, warning):
|
||||
def find_source(app, modname):
|
||||
if modname == 'not_a_package':
|
||||
source = (app.srcdir / 'not_a_package/__init__.py').read_text()
|
||||
source = (app.srcdir / 'not_a_package/__init__.py').read_text(encoding='utf8')
|
||||
tags = {
|
||||
'func1': ('def', 1, 1),
|
||||
'Class1': ('class', 1, 1),
|
||||
@@ -86,7 +86,7 @@ def test_local_source_files(app, status, warning):
|
||||
'not_a_package.submodule.Class1': ('class', 1, 1),
|
||||
}
|
||||
else:
|
||||
source = (app.srcdir / 'not_a_package/submodule.py').read_text()
|
||||
source = (app.srcdir / 'not_a_package/submodule.py').read_text(encoding='utf8')
|
||||
tags = {
|
||||
'not_a_package.submodule.func1': ('def', 11, 15),
|
||||
'Class1': ('class', 19, 22),
|
||||
@@ -106,7 +106,7 @@ def test_local_source_files(app, status, warning):
|
||||
warnings
|
||||
)
|
||||
|
||||
result = (app.outdir / 'index.html').read_text()
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert result.count('href="_modules/not_a_package.html#func1"') == 1
|
||||
assert result.count('href="_modules/not_a_package.html#not_a_package.submodule.func1"') == 1
|
||||
assert result.count('href="_modules/not_a_package/submodule.html#Class1"') == 1
|
||||
|
||||
@@ -105,7 +105,7 @@ def test_text_emit_warnings(app, warning):
|
||||
def test_text_warning_node(app):
|
||||
app.build()
|
||||
# test warnings in translation
|
||||
result = (app.outdir / 'warnings.txt').read_text()
|
||||
result = (app.outdir / 'warnings.txt').read_text(encoding='utf8')
|
||||
expect = ("3. I18N WITH REST WARNINGS"
|
||||
"\n**************************\n"
|
||||
"\nLINE OF >>``<<BROKEN LITERAL MARKUP.\n")
|
||||
@@ -119,7 +119,7 @@ def test_text_warning_node(app):
|
||||
def test_text_title_underline(app):
|
||||
app.build()
|
||||
# --- simple translation; check title underlines
|
||||
result = (app.outdir / 'bom.txt').read_text()
|
||||
result = (app.outdir / 'bom.txt').read_text(encoding='utf8')
|
||||
expect = ("2. Datei mit UTF-8"
|
||||
"\n******************\n" # underline matches new translation
|
||||
"\nThis file has umlauts: äöü.\n")
|
||||
@@ -132,7 +132,7 @@ def test_text_title_underline(app):
|
||||
def test_text_subdirs(app):
|
||||
app.build()
|
||||
# --- check translation in subdirs
|
||||
result = (app.outdir / 'subdir' / 'index.txt').read_text()
|
||||
result = (app.outdir / 'subdir' / 'index.txt').read_text(encoding='utf8')
|
||||
assert_startswith(result, "1. subdir contents\n******************\n")
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ def test_text_subdirs(app):
|
||||
def test_text_inconsistency_warnings(app, warning):
|
||||
app.build()
|
||||
# --- check warnings for inconsistency in number of references
|
||||
result = (app.outdir / 'refs_inconsistency.txt').read_text()
|
||||
result = (app.outdir / 'refs_inconsistency.txt').read_text(encoding='utf8')
|
||||
expect = ("8. I18N WITH REFS INCONSISTENCY"
|
||||
"\n*******************************\n"
|
||||
"\n* FOR CITATION [ref3].\n"
|
||||
@@ -191,7 +191,7 @@ def test_text_inconsistency_warnings(app, warning):
|
||||
@pytest.mark.test_params(shared_result='test_intl_basic')
|
||||
def test_noqa(app, warning):
|
||||
app.build()
|
||||
result = (app.outdir / 'noqa.txt').read_text()
|
||||
result = (app.outdir / 'noqa.txt').read_text(encoding='utf8')
|
||||
expect = r"""FIRST SECTION
|
||||
*************
|
||||
|
||||
@@ -218,7 +218,7 @@ TO TEST BARE noqa.
|
||||
def test_text_literalblock_warnings(app, warning):
|
||||
app.build()
|
||||
# --- check warning for literal block
|
||||
result = (app.outdir / 'literalblock.txt').read_text()
|
||||
result = (app.outdir / 'literalblock.txt').read_text(encoding='utf8')
|
||||
expect = ("9. I18N WITH LITERAL BLOCK"
|
||||
"\n**************************\n"
|
||||
"\nCORRECT LITERAL BLOCK:\n"
|
||||
@@ -240,7 +240,7 @@ def test_text_literalblock_warnings(app, warning):
|
||||
def test_text_definition_terms(app):
|
||||
app.build()
|
||||
# --- definition terms: regression test for #975, #2198, #2205
|
||||
result = (app.outdir / 'definition_terms.txt').read_text()
|
||||
result = (app.outdir / 'definition_terms.txt').read_text(encoding='utf8')
|
||||
expect = ("13. I18N WITH DEFINITION TERMS"
|
||||
"\n******************************\n"
|
||||
"\nSOME TERM"
|
||||
@@ -260,7 +260,7 @@ def test_text_definition_terms(app):
|
||||
def test_text_glossary_term(app, warning):
|
||||
app.build()
|
||||
# --- glossary terms: regression test for #1090
|
||||
result = (app.outdir / 'glossary_terms.txt').read_text()
|
||||
result = (app.outdir / 'glossary_terms.txt').read_text(encoding='utf8')
|
||||
expect = (r"""18. I18N WITH GLOSSARY TERMS
|
||||
****************************
|
||||
|
||||
@@ -295,7 +295,7 @@ VVV
|
||||
def test_text_glossary_term_inconsistencies(app, warning):
|
||||
app.build()
|
||||
# --- glossary term inconsistencies: regression test for #1090
|
||||
result = (app.outdir / 'glossary_terms_inconsistency.txt').read_text()
|
||||
result = (app.outdir / 'glossary_terms_inconsistency.txt').read_text(encoding='utf8')
|
||||
expect = ("19. I18N WITH GLOSSARY TERMS INCONSISTENCY"
|
||||
"\n******************************************\n"
|
||||
"\n1. LINK TO *SOME NEW TERM*.\n")
|
||||
@@ -328,7 +328,7 @@ def test_gettext_section(app):
|
||||
def test_text_section(app):
|
||||
app.build()
|
||||
# --- section
|
||||
result = (app.outdir / 'section.txt').read_text()
|
||||
result = (app.outdir / 'section.txt').read_text(encoding='utf8')
|
||||
expect = read_po(app.srcdir / 'xx' / 'LC_MESSAGES' / 'section.po')
|
||||
for expect_msg in [m for m in expect if m.id]:
|
||||
assert expect_msg.string in result
|
||||
@@ -340,7 +340,7 @@ def test_text_section(app):
|
||||
def test_text_seealso(app):
|
||||
app.build()
|
||||
# --- seealso
|
||||
result = (app.outdir / 'seealso.txt').read_text()
|
||||
result = (app.outdir / 'seealso.txt').read_text(encoding='utf8')
|
||||
expect = ("12. I18N WITH SEEALSO"
|
||||
"\n*********************\n"
|
||||
"\nSee also: SHORT TEXT 1\n"
|
||||
@@ -357,7 +357,7 @@ def test_text_seealso(app):
|
||||
def test_text_figure_captions(app):
|
||||
app.build()
|
||||
# --- figure captions: regression test for #940
|
||||
result = (app.outdir / 'figure.txt').read_text()
|
||||
result = (app.outdir / 'figure.txt').read_text(encoding='utf8')
|
||||
expect = ("14. I18N WITH FIGURE CAPTION"
|
||||
"\n****************************\n"
|
||||
"\n [image]MY CAPTION OF THE FIGURE\n"
|
||||
@@ -401,7 +401,7 @@ def test_text_figure_captions(app):
|
||||
def test_text_rubric(app):
|
||||
app.build()
|
||||
# --- rubric: regression test for pull request #190
|
||||
result = (app.outdir / 'rubric.txt').read_text()
|
||||
result = (app.outdir / 'rubric.txt').read_text(encoding='utf8')
|
||||
expect = ("I18N WITH RUBRIC"
|
||||
"\n****************\n"
|
||||
"\n-[ RUBRIC TITLE ]-\n"
|
||||
@@ -419,7 +419,7 @@ def test_text_rubric(app):
|
||||
def test_text_docfields(app):
|
||||
app.build()
|
||||
# --- docfields
|
||||
result = (app.outdir / 'docfields.txt').read_text()
|
||||
result = (app.outdir / 'docfields.txt').read_text(encoding='utf8')
|
||||
expect = ("21. I18N WITH DOCFIELDS"
|
||||
"\n***********************\n"
|
||||
"\nclass Cls1\n"
|
||||
@@ -450,7 +450,7 @@ def test_text_admonitions(app):
|
||||
# --- admonitions
|
||||
# #1206: gettext did not translate admonition directive's title
|
||||
# seealso: https://docutils.sourceforge.io/docs/ref/rst/directives.html#admonitions
|
||||
result = (app.outdir / 'admonitions.txt').read_text()
|
||||
result = (app.outdir / 'admonitions.txt').read_text(encoding='utf8')
|
||||
directives = (
|
||||
"attention", "caution", "danger", "error", "hint",
|
||||
"important", "note", "tip", "warning", "admonition")
|
||||
@@ -497,7 +497,7 @@ def test_gettext_table(app):
|
||||
def test_text_table(app):
|
||||
app.build()
|
||||
# --- toctree
|
||||
result = (app.outdir / 'table.txt').read_text()
|
||||
result = (app.outdir / 'table.txt').read_text(encoding='utf8')
|
||||
expect = read_po(app.srcdir / 'xx' / 'LC_MESSAGES' / 'table.po')
|
||||
for expect_msg in [m for m in expect if m.id]:
|
||||
assert expect_msg.string in result
|
||||
@@ -510,11 +510,11 @@ def test_text_toctree(app):
|
||||
app.build()
|
||||
# --- toctree (index.rst)
|
||||
# Note: index.rst contains contents that is not shown in text.
|
||||
result = (app.outdir / 'index.txt').read_text()
|
||||
result = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
assert 'CONTENTS' in result
|
||||
assert 'TABLE OF CONTENTS' in result
|
||||
# --- toctree (toctree.rst)
|
||||
result = (app.outdir / 'toctree.txt').read_text()
|
||||
result = (app.outdir / 'toctree.txt').read_text(encoding='utf8')
|
||||
expect = read_po(app.srcdir / 'xx' / 'LC_MESSAGES' / 'toctree.po')
|
||||
for expect_msg in [m for m in expect if m.id]:
|
||||
assert expect_msg.string in result
|
||||
@@ -538,7 +538,7 @@ def test_gettext_topic(app):
|
||||
def test_text_topic(app):
|
||||
app.build()
|
||||
# --- topic
|
||||
result = (app.outdir / 'topic.txt').read_text()
|
||||
result = (app.outdir / 'topic.txt').read_text(encoding='utf8')
|
||||
expect = read_po(app.srcdir / 'xx' / 'LC_MESSAGES' / 'topic.po')
|
||||
for expect_msg in [m for m in expect if m.id]:
|
||||
assert expect_msg.string in result
|
||||
@@ -656,7 +656,7 @@ def test_gettext_dont_rebuild_mo(make_app, app_params):
|
||||
def test_html_meta(app):
|
||||
app.build()
|
||||
# --- test for meta
|
||||
result = (app.outdir / 'index.html').read_text()
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
expected_expr = '<meta content="TESTDATA FOR I18N" name="description" />'
|
||||
assert expected_expr in result
|
||||
expected_expr = '<meta content="I18N, SPHINX, MARKUP" name="keywords" />'
|
||||
@@ -672,7 +672,7 @@ def test_html_footnotes(app):
|
||||
app.build()
|
||||
# --- test for #955 cant-build-html-with-footnotes-when-using
|
||||
# expect no error by build
|
||||
(app.outdir / 'footnote.html').read_text()
|
||||
(app.outdir / 'footnote.html').read_text(encoding='utf8')
|
||||
|
||||
|
||||
@sphinx_intl
|
||||
@@ -681,7 +681,7 @@ def test_html_footnotes(app):
|
||||
def test_html_undefined_refs(app):
|
||||
app.build()
|
||||
# --- links to undefined reference
|
||||
result = (app.outdir / 'refs_inconsistency.html').read_text()
|
||||
result = (app.outdir / 'refs_inconsistency.html').read_text(encoding='utf8')
|
||||
|
||||
expected_expr = ('<a class="reference external" '
|
||||
'href="http://www.example.com">reference</a>')
|
||||
@@ -703,7 +703,7 @@ def test_html_undefined_refs(app):
|
||||
def test_html_index_entries(app):
|
||||
app.build()
|
||||
# --- index entries: regression test for #976
|
||||
result = (app.outdir / 'genindex.html').read_text()
|
||||
result = (app.outdir / 'genindex.html').read_text(encoding='utf8')
|
||||
|
||||
def wrap(tag, keyword):
|
||||
start_tag = "<%s[^>]*>" % tag
|
||||
@@ -741,7 +741,7 @@ def test_html_index_entries(app):
|
||||
def test_html_versionchanges(app):
|
||||
app.build()
|
||||
# --- versionchanges
|
||||
result = (app.outdir / 'versionchange.html').read_text()
|
||||
result = (app.outdir / 'versionchange.html').read_text(encoding='utf8')
|
||||
|
||||
def get_content(result, name):
|
||||
matched = re.search(r'<div class="%s">\n*(.*?)</div>' % name,
|
||||
@@ -778,7 +778,7 @@ def test_html_docfields(app):
|
||||
app.build()
|
||||
# --- docfields
|
||||
# expect no error by build
|
||||
(app.outdir / 'docfields.html').read_text()
|
||||
(app.outdir / 'docfields.html').read_text(encoding='utf8')
|
||||
|
||||
|
||||
@sphinx_intl
|
||||
@@ -787,7 +787,7 @@ def test_html_docfields(app):
|
||||
def test_html_template(app):
|
||||
app.build()
|
||||
# --- gettext template
|
||||
result = (app.outdir / 'contents.html').read_text()
|
||||
result = (app.outdir / 'contents.html').read_text(encoding='utf8')
|
||||
assert "WELCOME" in result
|
||||
assert "SPHINX 2013.120" in result
|
||||
|
||||
@@ -1084,7 +1084,7 @@ def test_xml_label_targets(app):
|
||||
def test_additional_targets_should_not_be_translated(app):
|
||||
app.build()
|
||||
# [literalblock.txt]
|
||||
result = (app.outdir / 'literalblock.html').read_text()
|
||||
result = (app.outdir / 'literalblock.html').read_text(encoding='utf8')
|
||||
|
||||
# title should be translated
|
||||
expected_expr = 'CODE-BLOCKS'
|
||||
@@ -1125,7 +1125,7 @@ def test_additional_targets_should_not_be_translated(app):
|
||||
|
||||
# [raw.txt]
|
||||
|
||||
result = (app.outdir / 'raw.html').read_text()
|
||||
result = (app.outdir / 'raw.html').read_text(encoding='utf8')
|
||||
|
||||
# raw block should not be translated
|
||||
if docutils.__version_info__ < (0, 17):
|
||||
@@ -1137,7 +1137,7 @@ def test_additional_targets_should_not_be_translated(app):
|
||||
|
||||
# [figure.txt]
|
||||
|
||||
result = (app.outdir / 'figure.html').read_text()
|
||||
result = (app.outdir / 'figure.html').read_text(encoding='utf8')
|
||||
|
||||
# src for image block should not be translated (alt is translated)
|
||||
expected_expr = """<img alt="I18N -> IMG" src="_images/i18n.png" />"""
|
||||
@@ -1167,7 +1167,7 @@ def test_additional_targets_should_not_be_translated(app):
|
||||
def test_additional_targets_should_be_translated(app):
|
||||
app.build()
|
||||
# [literalblock.txt]
|
||||
result = (app.outdir / 'literalblock.html').read_text()
|
||||
result = (app.outdir / 'literalblock.html').read_text(encoding='utf8')
|
||||
|
||||
# title should be translated
|
||||
expected_expr = 'CODE-BLOCKS'
|
||||
@@ -1211,7 +1211,7 @@ def test_additional_targets_should_be_translated(app):
|
||||
|
||||
# [raw.txt]
|
||||
|
||||
result = (app.outdir / 'raw.html').read_text()
|
||||
result = (app.outdir / 'raw.html').read_text(encoding='utf8')
|
||||
|
||||
# raw block should be translated
|
||||
if docutils.__version_info__ < (0, 17):
|
||||
@@ -1223,7 +1223,7 @@ def test_additional_targets_should_be_translated(app):
|
||||
|
||||
# [figure.txt]
|
||||
|
||||
result = (app.outdir / 'figure.html').read_text()
|
||||
result = (app.outdir / 'figure.html').read_text(encoding='utf8')
|
||||
|
||||
# alt and src for image block should be translated
|
||||
expected_expr = """<img alt="I18N -> IMG" src="_images/img.png" />"""
|
||||
@@ -1355,7 +1355,7 @@ def test_gettext_allow_fuzzy_translations(app):
|
||||
pofile.write_po(f, catalog)
|
||||
|
||||
app.build()
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert 'FEATURES' in content
|
||||
|
||||
|
||||
@@ -1374,7 +1374,7 @@ def test_gettext_disallow_fuzzy_translations(app):
|
||||
pofile.write_po(f, catalog)
|
||||
|
||||
app.build()
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert 'FEATURES' not in content
|
||||
|
||||
|
||||
@@ -1399,7 +1399,7 @@ def test_customize_system_message(make_app, app_params, sphinx_test_tempdir):
|
||||
assert app.translator.gettext('Quick search') == 'QUICK SEARCH'
|
||||
|
||||
app.build()
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert 'QUICK SEARCH' in content
|
||||
finally:
|
||||
locale.translators.clear()
|
||||
|
||||
@@ -100,7 +100,7 @@ def test_quickstart_defaults(tempdir):
|
||||
conffile = tempdir / 'conf.py'
|
||||
assert conffile.isfile()
|
||||
ns = {}
|
||||
exec(conffile.read_text(), ns)
|
||||
exec(conffile.read_text(encoding='utf8'), ns)
|
||||
assert ns['extensions'] == []
|
||||
assert ns['templates_path'] == ['_templates']
|
||||
assert ns['project'] == 'Sphinx Test'
|
||||
@@ -150,7 +150,7 @@ def test_quickstart_all_answers(tempdir):
|
||||
conffile = tempdir / 'source' / 'conf.py'
|
||||
assert conffile.isfile()
|
||||
ns = {}
|
||||
exec(conffile.read_text(), ns)
|
||||
exec(conffile.read_text(encoding='utf8'), ns)
|
||||
assert ns['extensions'] == [
|
||||
'sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.todo'
|
||||
]
|
||||
@@ -231,7 +231,7 @@ def test_default_filename(tempdir):
|
||||
conffile = tempdir / 'conf.py'
|
||||
assert conffile.isfile()
|
||||
ns = {}
|
||||
exec(conffile.read_text(), ns)
|
||||
exec(conffile.read_text(encoding='utf8'), ns)
|
||||
|
||||
|
||||
def test_extensions(tempdir):
|
||||
@@ -241,7 +241,7 @@ def test_extensions(tempdir):
|
||||
conffile = tempdir / 'conf.py'
|
||||
assert conffile.isfile()
|
||||
ns = {}
|
||||
exec(conffile.read_text(), ns)
|
||||
exec(conffile.read_text(encoding='utf8'), ns)
|
||||
assert ns['extensions'] == ['foo', 'bar', 'baz']
|
||||
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ def setup_module():
|
||||
|
||||
|
||||
def jsload(path):
|
||||
searchindex = path.read_text()
|
||||
searchindex = path.read_text(encoding='utf8')
|
||||
assert searchindex.startswith('Search.setIndex(')
|
||||
assert searchindex.endswith(')')
|
||||
|
||||
@@ -99,7 +99,7 @@ def test_meta_keys_are_handled_for_language_de(app, status, warning):
|
||||
@pytest.mark.sphinx(testroot='search')
|
||||
def test_stemmer_does_not_remove_short_words(app, status, warning):
|
||||
app.builder.build_all()
|
||||
searchindex = (app.outdir / 'searchindex.js').read_text()
|
||||
searchindex = (app.outdir / 'searchindex.js').read_text(encoding='utf8')
|
||||
assert 'zfs' in searchindex
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ def test_stemmer(app, status, warning):
|
||||
|
||||
@pytest.mark.sphinx(testroot='search')
|
||||
def test_term_in_heading_and_section(app, status, warning):
|
||||
searchindex = (app.outdir / 'searchindex.js').read_text()
|
||||
searchindex = (app.outdir / 'searchindex.js').read_text(encoding='utf8')
|
||||
# if search term is in the title of one doc and in the text of another
|
||||
# both documents should be a hit in the search index as a title,
|
||||
# respectively text hit
|
||||
@@ -261,7 +261,7 @@ def test_IndexBuilder_lookup():
|
||||
def test_search_index_gen_zh(app, status, warning):
|
||||
app.builder.build_all()
|
||||
# jsdump fails if search language is 'zh'; hence we just get the text:
|
||||
searchindex = (app.outdir / 'searchindex.js').read_text()
|
||||
searchindex = (app.outdir / 'searchindex.js').read_text(encoding='utf8')
|
||||
assert 'chinesetest ' not in searchindex
|
||||
assert 'chinesetest' in searchindex
|
||||
assert 'chinesetesttwo' in searchindex
|
||||
|
||||
@@ -86,7 +86,7 @@ def nonascii_srcdir(request, setup_command):
|
||||
"""))
|
||||
|
||||
root_doc = srcdir / 'index.txt'
|
||||
root_doc.write_bytes((root_doc.read_text() + dedent("""
|
||||
root_doc.write_bytes((root_doc.read_text(encoding='utf8') + dedent("""
|
||||
.. toctree::
|
||||
|
||||
%(mb_name)s/%(mb_name)s
|
||||
|
||||
@@ -9,7 +9,7 @@ from html5lib import HTMLParser
|
||||
def test_basic(app, status, warning):
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert '<p>– “Sphinx” is a tool that makes it easy …</p>' in content
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ def test_literals(app, status, warning):
|
||||
def test_text_builder(app, status, warning):
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'index.txt').read_text()
|
||||
content = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
assert '-- "Sphinx" is a tool that makes it easy ...' in content
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ def test_text_builder(app, status, warning):
|
||||
def test_man_builder(app, status, warning):
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'python.1').read_text()
|
||||
content = (app.outdir / 'python.1').read_text(encoding='utf8')
|
||||
if docutils.__version_info__ > (0, 18):
|
||||
assert r'\-\- \(dqSphinx\(dq is a tool that makes it easy ...' in content
|
||||
else:
|
||||
@@ -54,7 +54,7 @@ def test_man_builder(app, status, warning):
|
||||
def test_latex_builder(app, status, warning):
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'python.tex').read_text()
|
||||
content = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
assert '\\textendash{} “Sphinx” is a tool that makes it easy …' in content
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ def test_latex_builder(app, status, warning):
|
||||
def test_ja_html_builder(app, status, warning):
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert '<p>-- "Sphinx" is a tool that makes it easy ...</p>' in content
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ def test_ja_html_builder(app, status, warning):
|
||||
def test_smartquotes_disabled(app, status, warning):
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert '<p>-- "Sphinx" is a tool that makes it easy ...</p>' in content
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ def test_smartquotes_disabled(app, status, warning):
|
||||
def test_smartquotes_action(app, status, warning):
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert '<p>-- “Sphinx” is a tool that makes it easy ...</p>' in content
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ def test_smartquotes_action(app, status, warning):
|
||||
def test_smartquotes_excludes_language(app, status, warning):
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert '<p>– 「Sphinx」 is a tool that makes it easy …</p>' in content
|
||||
|
||||
|
||||
@@ -99,5 +99,5 @@ def test_smartquotes_excludes_language(app, status, warning):
|
||||
def test_smartquotes_excludes_builders(app, status, warning):
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'python.1').read_text()
|
||||
content = (app.outdir / 'python.1').read_text(encoding='utf8')
|
||||
assert '– “Sphinx” is a tool that makes it easy …' in content
|
||||
|
||||
@@ -12,7 +12,7 @@ def test_layout_overloading(make_app, app_params):
|
||||
setup_documenters(app)
|
||||
app.builder.build_update()
|
||||
|
||||
result = (app.outdir / 'index.html').read_text()
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert '<!-- layout overloading -->' in result
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ def test_autosummary_class_template_overloading(make_app, app_params):
|
||||
setup_documenters(app)
|
||||
app.builder.build_update()
|
||||
|
||||
result = (app.outdir / 'generated' / 'sphinx.application.TemplateBridge.html').read_text()
|
||||
result = (app.outdir / 'generated' / 'sphinx.application.TemplateBridge.html').read_text(encoding='utf8')
|
||||
assert 'autosummary/class.rst method block overloading' in result
|
||||
assert 'foobar' not in result
|
||||
|
||||
@@ -36,6 +36,6 @@ def test_autosummary_context(make_app, app_params):
|
||||
setup_documenters(app)
|
||||
app.builder.build_update()
|
||||
|
||||
result = (app.outdir / 'generated' / 'sphinx.application.TemplateBridge.html').read_text()
|
||||
result = (app.outdir / 'generated' / 'sphinx.application.TemplateBridge.html').read_text(encoding='utf8')
|
||||
assert 'autosummary/class.rst method block overloading' in result
|
||||
assert 'foobar' in result
|
||||
|
||||
@@ -68,16 +68,16 @@ def test_js_source(app, status, warning):
|
||||
|
||||
v = '3.5.1'
|
||||
msg = 'jquery.js version does not match to {v}'.format(v=v)
|
||||
jquery_min = (app.outdir / '_static' / 'jquery.js').read_text()
|
||||
jquery_min = (app.outdir / '_static' / 'jquery.js').read_text(encoding='utf8')
|
||||
assert 'jQuery v{v}'.format(v=v) in jquery_min, msg
|
||||
jquery_src = (app.outdir / '_static' / 'jquery-{v}.js'.format(v=v)).read_text()
|
||||
jquery_src = (app.outdir / '_static' / 'jquery-{v}.js'.format(v=v)).read_text(encoding='utf8')
|
||||
assert 'jQuery JavaScript Library v{v}'.format(v=v) in jquery_src, msg
|
||||
|
||||
v = '1.13.1'
|
||||
msg = 'underscore.js version does not match to {v}'.format(v=v)
|
||||
underscore_min = (app.outdir / '_static' / 'underscore.js').read_text()
|
||||
underscore_min = (app.outdir / '_static' / 'underscore.js').read_text(encoding='utf8')
|
||||
assert 'Underscore.js {v}'.format(v=v) in underscore_min, msg
|
||||
underscore_src = (app.outdir / '_static' / 'underscore-{v}.js'.format(v=v)).read_text()
|
||||
underscore_src = (app.outdir / '_static' / 'underscore-{v}.js'.format(v=v)).read_text(encoding='utf8')
|
||||
assert 'Underscore.js {v}'.format(v=v) in underscore_src, msg
|
||||
|
||||
|
||||
@@ -100,12 +100,12 @@ def test_staticfiles(app, status, warning):
|
||||
app.build()
|
||||
assert (app.outdir / '_static' / 'staticimg.png').exists()
|
||||
assert (app.outdir / '_static' / 'statictmpl.html').exists()
|
||||
assert (app.outdir / '_static' / 'statictmpl.html').read_text() == (
|
||||
assert (app.outdir / '_static' / 'statictmpl.html').read_text(encoding='utf8') == (
|
||||
'<!-- testing static templates -->\n'
|
||||
'<html><project>Python</project></html>'
|
||||
)
|
||||
|
||||
result = (app.outdir / 'index.html').read_text()
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert '<meta name="testopt" content="optdefault" />' in result
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ def test_dark_style(app, status, warning):
|
||||
app.build()
|
||||
assert (app.outdir / '_static' / 'pygments_dark.css').exists()
|
||||
|
||||
result = (app.outdir / 'index.html').read_text()
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert '<link rel="stylesheet" type="text/css" href="_static/pygments.css" />' in result
|
||||
assert ('<link id="pygments_dark_css" media="(prefers-color-scheme: dark)" '
|
||||
'rel="stylesheet" type="text/css" '
|
||||
@@ -130,7 +130,7 @@ def test_theme_sidebars(app, status, warning):
|
||||
app.build()
|
||||
|
||||
# test-theme specifies globaltoc and searchbox as default sidebars
|
||||
result = (app.outdir / 'index.html').read_text()
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert '<h3><a href="#">Table of Contents</a></h3>' in result
|
||||
assert '<h3>Related Topics</h3>' not in result
|
||||
assert '<h3>This Page</h3>' not in result
|
||||
|
||||
@@ -33,7 +33,7 @@ def test_singlehtml_toctree(app, status, warning):
|
||||
@pytest.mark.sphinx(testroot='toctree', srcdir="numbered-toctree")
|
||||
def test_numbered_toctree(app, status, warning):
|
||||
# give argument to :numbered: option
|
||||
index = (app.srcdir / 'index.rst').read_text()
|
||||
index = (app.srcdir / 'index.rst').read_text(encoding='utf8')
|
||||
index = re.sub(':numbered:.*', ':numbered: 1', index)
|
||||
(app.srcdir / 'index.rst').write_text(index)
|
||||
app.builder.build_all()
|
||||
|
||||
@@ -10,7 +10,7 @@ def test_nitpicky_warning(app, status, warning):
|
||||
assert ('index.rst:4: WARNING: py:class reference target '
|
||||
'not found: io.StringIO' in warning.getvalue())
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert ('<p><code class="xref py py-class docutils literal notranslate"><span class="pre">'
|
||||
'io.StringIO</span></code></p>' in content)
|
||||
|
||||
@@ -31,7 +31,7 @@ def test_missing_reference(app, status, warning):
|
||||
app.build()
|
||||
assert warning.getvalue() == ''
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert '<p><span>missing-reference.StringIO</span></p>' in content
|
||||
|
||||
|
||||
@@ -46,5 +46,5 @@ def test_missing_reference_conditional_pending_xref(app, status, warning):
|
||||
app.build()
|
||||
assert warning.getvalue() == ''
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert '<span class="n"><span class="pre">Age</span></span>' in content
|
||||
|
||||
@@ -5,7 +5,7 @@ import pytest
|
||||
def test_trim_doctest_flags_html(app, status, warning):
|
||||
app.build()
|
||||
|
||||
result = (app.outdir / 'index.html').read_text()
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert 'FOO' not in result
|
||||
assert 'BAR' in result
|
||||
assert 'BAZ' not in result
|
||||
@@ -20,7 +20,7 @@ def test_trim_doctest_flags_html(app, status, warning):
|
||||
def test_trim_doctest_flags_disabled(app, status, warning):
|
||||
app.build()
|
||||
|
||||
result = (app.outdir / 'index.html').read_text()
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert 'FOO' in result
|
||||
assert 'BAR' in result
|
||||
assert 'BAZ' in result
|
||||
@@ -34,7 +34,7 @@ def test_trim_doctest_flags_disabled(app, status, warning):
|
||||
def test_trim_doctest_flags_latex(app, status, warning):
|
||||
app.build()
|
||||
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
assert 'FOO' not in result
|
||||
assert 'BAR' in result
|
||||
assert 'BAZ' not in result
|
||||
|
||||
@@ -25,7 +25,7 @@ def test_copy_asset_file(tempdir):
|
||||
|
||||
copy_asset_file(src, dest)
|
||||
assert dest.exists()
|
||||
assert src.read_text() == dest.read_text()
|
||||
assert src.read_text(encoding='utf8') == dest.read_text(encoding='utf8')
|
||||
|
||||
# copy template file
|
||||
src = (tempdir / 'asset.txt_t')
|
||||
@@ -35,7 +35,7 @@ def test_copy_asset_file(tempdir):
|
||||
copy_asset_file(src, dest, {'var1': 'template'}, renderer)
|
||||
assert not dest.exists()
|
||||
assert (tempdir / 'output.txt').exists()
|
||||
assert (tempdir / 'output.txt').read_text() == '# template data'
|
||||
assert (tempdir / 'output.txt').read_text(encoding='utf8') == '# template data'
|
||||
|
||||
# copy template file to subdir
|
||||
src = (tempdir / 'asset.txt_t')
|
||||
@@ -45,7 +45,7 @@ def test_copy_asset_file(tempdir):
|
||||
|
||||
copy_asset_file(src, subdir1, {'var1': 'template'}, renderer)
|
||||
assert (subdir1 / 'asset.txt').exists()
|
||||
assert (subdir1 / 'asset.txt').read_text() == '# template data'
|
||||
assert (subdir1 / 'asset.txt').read_text(encoding='utf8') == '# template data'
|
||||
|
||||
# copy template file without context
|
||||
src = (tempdir / 'asset.txt_t')
|
||||
@@ -55,7 +55,7 @@ def test_copy_asset_file(tempdir):
|
||||
copy_asset_file(src, subdir2)
|
||||
assert not (subdir2 / 'asset.txt').exists()
|
||||
assert (subdir2 / 'asset.txt_t').exists()
|
||||
assert (subdir2 / 'asset.txt_t').read_text() == '# {{var1}} data'
|
||||
assert (subdir2 / 'asset.txt_t').read_text(encoding='utf8') == '# {{var1}} data'
|
||||
|
||||
|
||||
def test_copy_asset(tempdir):
|
||||
@@ -83,11 +83,11 @@ def test_copy_asset(tempdir):
|
||||
copy_asset(source, destdir, context=dict(var1='bar', var2='baz'), renderer=renderer)
|
||||
assert (destdir / 'index.rst').exists()
|
||||
assert (destdir / 'foo.rst').exists()
|
||||
assert (destdir / 'foo.rst').read_text() == 'bar.rst'
|
||||
assert (destdir / 'foo.rst').read_text(encoding='utf8') == 'bar.rst'
|
||||
assert (destdir / '_static' / 'basic.css').exists()
|
||||
assert (destdir / '_templates' / 'layout.html').exists()
|
||||
assert (destdir / '_templates' / 'sidebar.html').exists()
|
||||
assert (destdir / '_templates' / 'sidebar.html').read_text() == 'sidebar: baz'
|
||||
assert (destdir / '_templates' / 'sidebar.html').read_text(encoding='utf8') == 'sidebar: baz'
|
||||
|
||||
# copy with exclusion
|
||||
def excluded(path):
|
||||
|
||||
Reference in New Issue
Block a user