diff options
Diffstat (limited to 'tests')
38 files changed, 297 insertions, 297 deletions
diff --git a/tests/test_build.py b/tests/test_build.py index de73cb6d9..9dcf78165 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -45,7 +45,7 @@ def nonascii_srcdir(request, rootdir, sphinx_test_tempdir): """)) master_doc = srcdir / 'index.txt' - master_doc.write_text(master_doc.text() + dedent(""" + master_doc.write_text(master_doc.read_text() + dedent(""" .. toctree:: %(test_name)s/%(test_name)s diff --git a/tests/test_build_changes.py b/tests/test_build_changes.py index 5adaa5777..2e87fe0bf 100644 --- a/tests/test_build_changes.py +++ b/tests/test_build_changes.py @@ -17,7 +17,7 @@ def test_build(app): app.build() # TODO: Use better checking of html content - htmltext = (app.outdir / 'changes.html').text() + htmltext = (app.outdir / 'changes.html').read_text() 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 diff --git a/tests/test_build_epub.py b/tests/test_build_epub.py index 9436ac020..a5780b04f 100644 --- a/tests/test_build_epub.py +++ b/tests/test_build_epub.py @@ -67,11 +67,11 @@ class EPUBElementTree: @pytest.mark.sphinx('epub', testroot='basic') def test_build_epub(app): app.build() - assert (app.outdir / 'mimetype').text() == 'application/epub+zip' + assert (app.outdir / 'mimetype').read_text() == 'application/epub+zip' assert (app.outdir / 'META-INF' / 'container.xml').exists() # toc.ncx - toc = EPUBElementTree.fromstring((app.outdir / 'toc.ncx').text()) + toc = EPUBElementTree.fromstring((app.outdir / 'toc.ncx').read_text()) assert toc.find("./ncx:docTitle/ncx:text").text == 'Python' # toc.ncx / head @@ -91,7 +91,7 @@ def test_build_epub(app): assert navlabel.text == 'The basic Sphinx documentation for testing' # content.opf - opf = EPUBElementTree.fromstring((app.outdir / 'content.opf').text()) + opf = EPUBElementTree.fromstring((app.outdir / 'content.opf').read_text()) # content.opf / metadata metadata = opf.find("./idpf:metadata") @@ -143,7 +143,7 @@ def test_build_epub(app): assert reference.get('href') == 'index.xhtml' # nav.xhtml - nav = EPUBElementTree.fromstring((app.outdir / 'nav.xhtml').text()) + nav = EPUBElementTree.fromstring((app.outdir / 'nav.xhtml').read_text()) 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' @@ -163,7 +163,7 @@ def test_epub_cover(app): app.build() # content.opf / metadata - opf = EPUBElementTree.fromstring((app.outdir / 'content.opf').text()) + opf = EPUBElementTree.fromstring((app.outdir / 'content.opf').read_text()) 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 @@ -175,7 +175,7 @@ def test_nested_toc(app): app.build() # toc.ncx - toc = EPUBElementTree.fromstring((app.outdir / 'toc.ncx').bytes()) + toc = EPUBElementTree.fromstring((app.outdir / 'toc.ncx').read_bytes()) assert toc.find("./ncx:docTitle/ncx:text").text == 'Python' # toc.ncx / navPoint @@ -205,7 +205,7 @@ def test_nested_toc(app): anchor = elem.find("./xhtml:a") return (anchor.get('href'), anchor.text) - nav = EPUBElementTree.fromstring((app.outdir / 'nav.xhtml').bytes()) + nav = EPUBElementTree.fromstring((app.outdir / 'nav.xhtml').read_bytes()) toc = nav.findall("./xhtml:body/xhtml:nav/xhtml:ol/xhtml:li") assert len(toc) == 4 assert navinfo(toc[0]) == ('index.xhtml', @@ -230,7 +230,7 @@ def test_escaped_toc(app): app.build() # toc.ncx - toc = EPUBElementTree.fromstring((app.outdir / 'toc.ncx').bytes()) + toc = EPUBElementTree.fromstring((app.outdir / 'toc.ncx').read_bytes()) assert toc.find("./ncx:docTitle/ncx:text").text == 'need <b>"escaped"</b> project' # toc.ncx / navPoint @@ -260,7 +260,7 @@ def test_escaped_toc(app): anchor = elem.find("./xhtml:a") return (anchor.get('href'), anchor.text) - nav = EPUBElementTree.fromstring((app.outdir / 'nav.xhtml').bytes()) + nav = EPUBElementTree.fromstring((app.outdir / 'nav.xhtml').read_bytes()) toc = nav.findall("./xhtml:body/xhtml:nav/xhtml:ol/xhtml:li") assert len(toc) == 4 assert navinfo(toc[0]) == ('index.xhtml', @@ -286,7 +286,7 @@ def test_epub_writing_mode(app): app.build() # horizontal / page-progression-direction - opf = EPUBElementTree.fromstring((app.outdir / 'content.opf').text()) + opf = EPUBElementTree.fromstring((app.outdir / 'content.opf').read_text()) assert opf.find("./idpf:spine").get('page-progression-direction') == 'ltr' # horizontal / ibooks:scroll-axis @@ -294,7 +294,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').text() + css = (app.outdir / '_static' / 'epub.css').read_text() assert 'writing-mode: horizontal-tb;' in css # vertical @@ -303,7 +303,7 @@ def test_epub_writing_mode(app): app.build() # vertical / page-progression-direction - opf = EPUBElementTree.fromstring((app.outdir / 'content.opf').text()) + opf = EPUBElementTree.fromstring((app.outdir / 'content.opf').read_text()) assert opf.find("./idpf:spine").get('page-progression-direction') == 'rtl' # vertical / ibooks:scroll-axis @@ -311,7 +311,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').text() + css = (app.outdir / '_static' / 'epub.css').read_text() assert 'writing-mode: vertical-rl;' in css @@ -319,7 +319,7 @@ def test_epub_writing_mode(app): def test_epub_anchor_id(app): app.build() - html = (app.outdir / 'index.xhtml').text() + html = (app.outdir / 'index.xhtml').read_text() assert '<p id="std-setting-STATICFILES_FINDERS">blah blah blah</p>' in html assert '<span id="std-setting-STATICFILES_SECTION"></span><h1>blah blah blah</h1>' in html assert 'see <a class="reference internal" href="#std-setting-STATICFILES_FINDERS">' in html @@ -330,7 +330,7 @@ def test_epub_assets(app): app.builder.build_all() # epub_sytlesheets (same as html_css_files) - content = (app.outdir / 'index.xhtml').text() + content = (app.outdir / 'index.xhtml').read_text() 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" ' @@ -343,7 +343,7 @@ def test_epub_css_files(app): app.builder.build_all() # epub_css_files - content = (app.outdir / 'index.xhtml').text() + content = (app.outdir / 'index.xhtml').read_text() assert '<link rel="stylesheet" type="text/css" href="_static/css/epub.css" />' in content # files in html_css_files are not outputed @@ -360,7 +360,7 @@ def test_html_download_role(app, status, warning): app.build() assert not (app.outdir / '_downloads' / 'dummy.dat').exists() - content = (app.outdir / 'index.xhtml').text() + content = (app.outdir / 'index.xhtml').read_text() 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">' diff --git a/tests/test_build_gettext.py b/tests/test_build_gettext.py index a6107167a..1c86b8daa 100644 --- a/tests/test_build_gettext.py +++ b/tests/test_build_gettext.py @@ -31,7 +31,7 @@ def test_build_gettext(app): assert (app.outdir / 'subdir.pot').isfile() # regression test for issue #960 - catalog = (app.outdir / 'markup.pot').text() + catalog = (app.outdir / 'markup.pot').read_text() assert 'msgid "something, something else, something more"' in catalog @@ -84,7 +84,7 @@ def test_gettext_index_entries(app): return m.groups()[0] return None - pot = (app.outdir / 'index_entries.pot').text() + pot = (app.outdir / 'index_entries.pot').read_text() msgids = [_f for _f in map(msgid_getter, pot.splitlines()) if _f] expected_msgids = [ @@ -133,7 +133,7 @@ def test_gettext_disable_index_entries(app): return m.groups()[0] return None - pot = (app.outdir / 'index_entries.pot').text() + pot = (app.outdir / 'index_entries.pot').read_text() msgids = [_f for _f in map(msgid_getter, pot.splitlines()) if _f] expected_msgids = [ @@ -156,7 +156,7 @@ def test_gettext_template(app): app.builder.build_all() assert (app.outdir / 'sphinx.pot').isfile() - result = (app.outdir / 'sphinx.pot').text() + result = (app.outdir / 'sphinx.pot').read_text() assert "Welcome" in result assert "Sphinx %(version)s" in result @@ -166,7 +166,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').text() + result = (app.outdir / 'sphinx.pot').read_text() assert re.search( ('msgid "Template 1".*' 'msgid "This is Template 1\\.".*' diff --git a/tests/test_build_html.py b/tests/test_build_html.py index 1d37488fe..a9914d9a0 100644 --- a/tests/test_build_html.py +++ b/tests/test_build_html.py @@ -426,7 +426,7 @@ def test_html_download(app): app.build() # subdir/includes.html - result = (app.outdir / 'subdir' / 'includes.html').text() + result = (app.outdir / 'subdir' / 'includes.html').read_text() pattern = ('<a class="reference download internal" download="" ' 'href="../(_downloads/.*/img.png)">') matched = re.search(pattern, result) @@ -435,7 +435,7 @@ def test_html_download(app): filename = matched.group(1) # includes.html - result = (app.outdir / 'includes.html').text() + result = (app.outdir / 'includes.html').read_text() pattern = ('<a class="reference download internal" download="" ' 'href="(_downloads/.*/img.png)">') matched = re.search(pattern, result) @@ -454,7 +454,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').text() + content = (app.outdir / 'index.html').read_text() assert (('<li><p><a class="reference download internal" download="" ' 'href="_downloads/%s/dummy.dat">' '<code class="xref download docutils literal notranslate">' @@ -646,7 +646,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').text() + index = (app.srcdir / 'index.rst').read_text() index = re.sub(':numbered:.*', '', index) (app.srcdir / 'index.rst').write_text(index) app.builder.build_all() @@ -746,7 +746,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').text() + index = (app.srcdir / 'index.rst').read_text() index = re.sub(':numbered:.*', '', index) (app.srcdir / 'index.rst').write_text(index) @@ -1189,7 +1189,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').text() == 'Sphinx-1.4.4' + assert (app.outdir / '_static' / 'API.html').read_text() == '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() @@ -1210,7 +1210,7 @@ def test_html_assets(app): assert not (app.outdir / 'subdir' / '.htpasswd').exists() # html_css_files - content = (app.outdir / 'index.html').text() + content = (app.outdir / 'index.html').read_text() 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) @@ -1249,7 +1249,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').text() + content = (app.outdir / 'index.html').read_text() for entity in re.findall(r'&([a-z]+);', content, re.M): assert entity not in valid_entities @@ -1284,7 +1284,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').text() + content = (app.outdir / 'index.html').read_text() 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>' in content) @@ -1293,7 +1293,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').text(encoding='utf8') + result = (app.outdir / 'index.html').read_text(encoding='utf8') # standard case assert 'standalone raw directive (HTML)' in result @@ -1337,7 +1337,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').text() + result = (app.outdir / 'index.html').read_text() assert '<link rel="stylesheet" href="_static/default.css" type="text/css" />' in result assert ('<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />' not in result) @@ -1347,7 +1347,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').text(encoding='utf8') + 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() @@ -1359,7 +1359,7 @@ def test_html_sidebar(app, status, warning): # default for alabaster app.builder.build_all() - result = (app.outdir / 'index.html').text(encoding='utf8') + 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 @@ -1374,7 +1374,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').text(encoding='utf8') + 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 @@ -1388,7 +1388,7 @@ def test_html_sidebar(app, status, warning): # no sidebars app.config.html_sidebars = {'**': []} app.builder.build_all() - result = (app.outdir / 'index.html').text(encoding='utf8') + 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 @@ -1419,10 +1419,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').text(encoding='utf8') + 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').text(encoding='utf8') + result = (app.outdir / 'qux' / 'index.html').read_text(encoding='utf8') assert '<link rel="canonical" href="https://example.com/qux/index.html" />' in result @@ -1432,10 +1432,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').text(encoding='utf8') + 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').text(encoding='utf8') + result = (app.outdir / 'qux' / 'index.htm').read_text(encoding='utf8') assert '<link rel="canonical" href="https://example.com/subdir/qux/index.htm" />' in result diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index 7a1a32507..9f3f0320b 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -113,7 +113,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').text(encoding='utf8') + result = (app.outdir / 'sphinxtests.tex').read_text(encoding='utf8') assert ('\\begin{sphinxfigure-in-table}\n\\centering\n\\capstart\n' '\\noindent\\sphinxincludegraphics{{img}.png}\n' @@ -156,7 +156,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').text(encoding='utf8') + result = (app.outdir / 'test.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -168,7 +168,7 @@ def test_latex_basic(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').text(encoding='utf8') + result = (app.outdir / 'test.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -178,7 +178,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').text(encoding='utf8') + result = (app.outdir / 'test.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -189,7 +189,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').text(encoding='utf8') + result = (app.outdir / 'test.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -200,7 +200,7 @@ def test_latex_title_after_admonitions(app, status, warning): confoverrides={'release': '1.0'}) def test_latex_release(app, status, warning): app.builder.build_all() - result = (app.outdir / 'test.tex').text(encoding='utf8') + result = (app.outdir / 'test.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -212,7 +212,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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -238,7 +238,7 @@ def test_numref(app, status, warning): '\\nameref{\\detokenize{foo:foo}}}') in result # sphinxmessages.sty - result = (app.outdir / 'sphinxmessages.sty').text(encoding='utf8') + 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 @@ -254,7 +254,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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -286,7 +286,7 @@ def test_numref_with_prefix1(app, status, warning): '\\nameref{\\detokenize{foo:foo}}}') in result # sphinxmessages.sty - result = (app.outdir / 'sphinxmessages.sty').text(encoding='utf8') + 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 @@ -302,7 +302,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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -328,7 +328,7 @@ def test_numref_with_prefix2(app, status, warning): '\\nameref{\\detokenize{foo:foo}}}') in result # sphinxmessages.sty - result = (app.outdir / 'sphinxmessages.sty').text(encoding='utf8') + 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 @@ -342,7 +342,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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -368,7 +368,7 @@ def test_numref_with_language_ja(app, status, warning): '\\nameref{\\detokenize{foo:foo}}}') in result # sphinxmessages.sty - result = (app.outdir / 'sphinxmessages.sty').text(encoding='utf8') + result = (app.outdir / 'sphinxmessages.sty').read_text(encoding='utf8') print(result) assert '\\@iden{\\renewcommand{\\figurename}{図 }}' in result assert '\\@iden{\\renewcommand{\\tablename}{表 }}' in result @@ -379,10 +379,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').text(encoding='utf8') + result = (app.outdir / 'SphinxManual.tex').read_text(encoding='utf8') assert '\\usepackage{sphinx}' in result - result = (app.outdir / 'SphinxHowTo.tex').text(encoding='utf8') + result = (app.outdir / 'SphinxHowTo.tex').read_text(encoding='utf8') assert '\\usepackage{sphinx}' in result @@ -392,10 +392,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').text(encoding='utf8') + result = (app.outdir / 'SphinxManual.tex').read_text(encoding='utf8') assert '\\usepackage[,nonumfigreset,mathnumfig]{sphinx}' in result - result = (app.outdir / 'SphinxHowTo.tex').text(encoding='utf8') + result = (app.outdir / 'SphinxHowTo.tex').read_text(encoding='utf8') assert '\\usepackage[,nonumfigreset,mathnumfig]{sphinx}' in result @@ -405,10 +405,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').text(encoding='utf8') + result = (app.outdir / 'SphinxManual.tex').read_text(encoding='utf8') assert '\\usepackage[,numfigreset=2,mathnumfig]{sphinx}' in result - result = (app.outdir / 'SphinxHowTo.tex').text(encoding='utf8') + result = (app.outdir / 'SphinxHowTo.tex').read_text(encoding='utf8') assert '\\usepackage[,numfigreset=3,mathnumfig]{sphinx}' in result @@ -418,10 +418,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').text(encoding='utf8') + result = (app.outdir / 'SphinxManual.tex').read_text(encoding='utf8') assert '\\usepackage[,numfigreset=1]{sphinx}' in result - result = (app.outdir / 'SphinxHowTo.tex').text(encoding='utf8') + result = (app.outdir / 'SphinxHowTo.tex').read_text(encoding='utf8') assert '\\usepackage[,numfigreset=2]{sphinx}' in result @@ -430,7 +430,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').text(encoding='utf8') + result = (app.outdir / 'test.tex').read_text(encoding='utf8') assert '\\usepackage{foo}' in result assert '\\usepackage[baz]{bar}' in result @@ -438,7 +438,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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -451,7 +451,7 @@ def test_babel_with_no_language_settings(app, status, warning): assert '\\shorthandoff' not in result # sphinxmessages.sty - result = (app.outdir / 'sphinxmessages.sty').text(encoding='utf8') + 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 @@ -463,7 +463,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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -476,7 +476,7 @@ def test_babel_with_language_de(app, status, warning): assert '\\shorthandoff{"}' in result # sphinxmessages.sty - result = (app.outdir / 'sphinxmessages.sty').text(encoding='utf8') + 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 @@ -488,7 +488,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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -501,7 +501,7 @@ def test_babel_with_language_ru(app, status, warning): assert '\\shorthandoff{"}' in result # sphinxmessages.sty - result = (app.outdir / 'sphinxmessages.sty').text(encoding='utf8') + 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 @@ -513,7 +513,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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -526,7 +526,7 @@ def test_babel_with_language_tr(app, status, warning): assert '\\shorthandoff{=}' in result # sphinxmessages.sty - result = (app.outdir / 'sphinxmessages.sty').text(encoding='utf8') + 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 @@ -538,7 +538,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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -550,7 +550,7 @@ def test_babel_with_language_ja(app, status, warning): assert '\\shorthandoff' not in result # sphinxmessages.sty - result = (app.outdir / 'sphinxmessages.sty').text(encoding='utf8') + result = (app.outdir / 'sphinxmessages.sty').read_text(encoding='utf8') print(result) assert r'\def\pageautorefname{ページ}' in result assert '\\@iden{\\renewcommand{\\figurename}{Fig.\\@{} }}' in result @@ -562,7 +562,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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -577,7 +577,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').text(encoding='utf8') + 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 @@ -589,7 +589,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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -603,7 +603,7 @@ def test_polyglossia_with_language_de(app, status, warning): assert '\\shorthandoff' not in result # sphinxmessages.sty - result = (app.outdir / 'sphinxmessages.sty').text(encoding='utf8') + 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 @@ -615,7 +615,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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -629,7 +629,7 @@ def test_polyglossia_with_language_de_1901(app, status, warning): assert '\\shorthandoff' not in result # sphinxmessages.sty - result = (app.outdir / 'sphinxmessages.sty').text(encoding='utf8') + 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 @@ -639,7 +639,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').text(encoding='utf8') + result = (app.outdir / 'sphinxtests.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -666,7 +666,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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -707,7 +707,7 @@ def test_reference_in_caption_and_codeblock_in_footnote(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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -752,7 +752,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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -806,7 +806,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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -856,7 +856,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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -882,7 +882,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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -899,7 +899,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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -913,7 +913,7 @@ def test_toctree_maxdepth_howto(app, status, warning): confoverrides={'master_doc': 'foo'}) def test_toctree_not_found(app, status, warning): app.builder.build_all() - result = (app.outdir / 'python.tex').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -927,7 +927,7 @@ def test_toctree_not_found(app, status, warning): confoverrides={'master_doc': 'bar'}) def test_toctree_without_maxdepth(app, status, warning): app.builder.build_all() - result = (app.outdir / 'python.tex').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -940,7 +940,7 @@ def test_toctree_without_maxdepth(app, status, warning): confoverrides={'master_doc': 'qux'}) def test_toctree_with_deeper_maxdepth(app, status, warning): app.builder.build_all() - result = (app.outdir / 'python.tex').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -953,7 +953,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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -965,7 +965,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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -983,7 +983,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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -997,7 +997,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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -1013,7 +1013,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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -1025,7 +1025,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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -1036,7 +1036,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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') print(result) print(status.getvalue()) print(warning.getvalue()) @@ -1049,14 +1049,14 @@ 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').text(encoding='utf8') + 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) tables[sectname] = content.strip() def get_expected(name): - return (app.srcdir / 'expects' / (name + '.tex')).text().strip() + return (app.srcdir / 'expects' / (name + '.tex')).read_text().strip() # simple_table actual = tables['simple table'] @@ -1120,14 +1120,14 @@ 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').text(encoding='utf8') + 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) tables[sectname] = content.strip() def get_expected(name): - return (app.srcdir / 'expects' / (name + '.tex')).text().strip() + return (app.srcdir / 'expects' / (name + '.tex')).read_text().strip() # longtable actual = tables['longtable'] @@ -1181,14 +1181,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').text(encoding='utf8') + 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')).text().strip() + return (app.srcdir / 'expects' / (name + '.tex')).read_text().strip() # grid table actual = tables['grid table'] @@ -1205,7 +1205,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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') assert 'SALUT LES COPAINS' in result @@ -1213,7 +1213,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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') assert 'SALUT LES COPAINS' not in result @@ -1221,14 +1221,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').text(encoding='utf8') + 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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') # standard case assert 'standalone raw directive (HTML)' not in result @@ -1244,7 +1244,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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') # images are copied assert '\\sphinxincludegraphics{{python-logo}.png}' in result @@ -1268,7 +1268,7 @@ def test_latex_images(app, status, warning): def test_latex_index(app, status, warning): app.builder.build_all() - result = (app.outdir / 'python.tex').text(encoding='utf8') + 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}}' @@ -1282,8 +1282,8 @@ def test_latex_index(app, status, warning): def test_latex_equations(app, status, warning): app.builder.build_all() - result = (app.outdir / 'python.tex').text(encoding='utf8') - expected = (app.srcdir / 'expects' / 'latex-equations.tex').text().strip() + result = (app.outdir / 'python.tex').read_text(encoding='utf8') + expected = (app.srcdir / 'expects' / 'latex-equations.tex').read_text().strip() assert expected in result @@ -1292,7 +1292,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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') assert ('{\\sphinxunactivateextrasandspace \\raisebox{-0.5\\height}' '{\\sphinxincludegraphics[height=2.00000cm]{{pic}.png}}' '}AFTER') in result @@ -1302,7 +1302,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').text(encoding='utf8') + 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' @@ -1319,7 +1319,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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') print(result) assert ('\\begin{sphinxthebibliography}{AuthorYe}\n' '\\bibitem[AuthorYear]{index:authoryear}\n' @@ -1332,7 +1332,7 @@ def test_latex_thebibliography(app, status, warning): def test_latex_glossary(app, status, warning): app.builder.build_all() - result = (app.outdir / 'python.tex').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') assert ('\\item[{änhlich\\index{änhlich@\\spxentry{änhlich}|spxpagem}' r'\phantomsection' r'\label{\detokenize{index:term-anhlich}}}] \leavevmode' in result) @@ -1356,7 +1356,7 @@ def test_latex_glossary(app, status, warning): def test_latex_labels(app, status, warning): app.builder.build_all() - result = (app.outdir / 'python.tex').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') # figures assert (r'\caption{labeled figure}' @@ -1403,7 +1403,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').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') assert(r'\begin{figure}[H]' in result) @@ -1433,7 +1433,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').text(encoding='utf8') + 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' @@ -1444,7 +1444,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').text() + result = (app.outdir / 'python.tex').read_text() print(result) assert 'script small e: e' in result assert 'double struck italic small i: i' in result @@ -1456,7 +1456,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').text() + result = (app.outdir / 'python.tex').read_text() print(result) assert 'script small e: e' in result assert 'double struck italic small i: i' in result @@ -1468,7 +1468,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').text() + result = (app.outdir / 'test.tex').read_text() assert r'\usepackage{foo}' in result diff --git a/tests/test_build_linkcheck.py b/tests/test_build_linkcheck.py index 22ed86e3e..7a01fb590 100644 --- a/tests/test_build_linkcheck.py +++ b/tests/test_build_linkcheck.py @@ -17,7 +17,7 @@ def test_defaults(app, status, warning): app.builder.build_all() assert (app.outdir / 'output.txt').exists() - content = (app.outdir / 'output.txt').text() + content = (app.outdir / 'output.txt').read_text() print(content) # looking for '#top' and 'does-not-exist' not found should fail @@ -44,7 +44,7 @@ def test_anchors_ignored(app, status, warning): app.builder.build_all() assert (app.outdir / 'output.txt').exists() - content = (app.outdir / 'output.txt').text() + content = (app.outdir / 'output.txt').read_text() # expect all ok when excluding #top assert not content diff --git a/tests/test_build_manpage.py b/tests/test_build_manpage.py index 902c58131..c3c41a2ae 100644 --- a/tests/test_build_manpage.py +++ b/tests/test_build_manpage.py @@ -19,7 +19,7 @@ def test_all(app, status, warning): app.builder.build_all() assert (app.outdir / 'sphinxtests.1').exists() - content = (app.outdir / 'sphinxtests.1').text() + content = (app.outdir / 'sphinxtests.1').read_text() assert r'\fBprint \fP\fIi\fP\fB\en\fP' in content assert r'\fBmanpage\en\fP' in content @@ -33,7 +33,7 @@ def test_all(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').text() + content = (app.outdir / 'python.1').read_text() assert ('.sp\n' 'caption \\fItest\\fP rb\n' @@ -64,5 +64,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').text() + content = (app.outdir / 'python.1').read_text() assert 'This is a rubric\n' in content diff --git a/tests/test_build_texinfo.py b/tests/test_build_texinfo.py index 247863bdb..44a037934 100644 --- a/tests/test_build_texinfo.py +++ b/tests/test_build_texinfo.py @@ -49,7 +49,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').text(encoding='utf8') + 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) @@ -70,7 +70,7 @@ def test_texinfo(app, status, warning): def test_texinfo_rubric(app, status, warning): app.build() - output = (app.outdir / 'python.texi').text() + output = (app.outdir / 'python.texi').read_text() assert '@heading This is a rubric' in output assert '@heading This is a multiline rubric' in output @@ -79,7 +79,7 @@ def test_texinfo_rubric(app, status, warning): def test_texinfo_citation(app, status, warning): app.builder.build_all() - output = (app.outdir / 'python.texi').text() + output = (app.outdir / 'python.texi').read_text() 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 diff --git a/tests/test_build_text.py b/tests/test_build_text.py index 6dc155f80..8dd6fabbf 100644 --- a/tests/test_build_text.py +++ b/tests/test_build_text.py @@ -26,7 +26,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').text() + result = (app.outdir / 'maxwidth.txt').read_text() lines = result.splitlines() line_widths = [column_width(line) for line in lines] @@ -49,7 +49,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').text() + result = (app.outdir / 'lineblock.txt').read_text() expect = ( "* one\n" "\n" @@ -64,7 +64,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').text() + result = (app.outdir / 'nonascii_title.txt').read_text() expect_underline = '*********' result_underline = result.splitlines()[1].strip() assert expect_underline == result_underline @@ -73,7 +73,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').text() + result = (app.outdir / 'nonascii_table.txt').read_text() 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 @@ -82,7 +82,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').text() + result = (app.outdir / 'nonascii_maxwidth.txt').read_text() 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 @@ -126,7 +126,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').text() + result = (app.outdir / 'table.txt').read_text() lines = [line.strip() for line in result.splitlines() if line.strip()] assert lines[0] == "+-------+-------+" assert lines[1] == "| XXX | XXX |" @@ -140,7 +140,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').text() + result = (app.outdir / 'table_rowspan.txt').read_text() lines = [line.strip() for line in result.splitlines() if line.strip()] assert lines[0] == "+-------+-------+" assert lines[1] == "| XXXXXXXXX |" @@ -154,7 +154,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').text() + result = (app.outdir / 'table_colspan.txt').read_text() lines = [line.strip() for line in result.splitlines() if line.strip()] assert lines[0] == "+-------+-------+" assert lines[1] == "| XXX | XXX |" @@ -168,7 +168,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').text() + result = (app.outdir / 'table_colspan_left.txt').read_text() lines = [line.strip() for line in result.splitlines() if line.strip()] assert lines[0] == "+-------+-------+" assert lines[1] == "| XXX | XXX |" @@ -182,7 +182,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').text() + result = (app.outdir / 'table_colspan_and_rowspan.txt').read_text() lines = [line.strip() for line in result.splitlines() if line.strip()] assert result assert lines[0] == "+-------+-------+-------+" @@ -197,7 +197,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').text() + result = (app.outdir / 'listitems.txt').read_text() lines = [line.rstrip() for line in result.splitlines()] assert lines[0] == "See also:" assert lines[1] == "" @@ -209,7 +209,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').text(encoding='utf8') + index = (app.outdir / 'index.txt').read_text(encoding='utf8') lines = index.splitlines() assert lines[0] == "* 1. Section A" assert lines[1] == "" @@ -218,7 +218,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').text(encoding='utf8') + doc2 = (app.outdir / 'doc2.txt').read_text(encoding='utf8') expect = ( "2. Section B\n" "************\n" @@ -235,7 +235,7 @@ def test_secnums(app, status, warning): app.config.text_secnumber_suffix = " " app.builder.build_all() - index = (app.outdir / 'index.txt').text(encoding='utf8') + index = (app.outdir / 'index.txt').read_text(encoding='utf8') lines = index.splitlines() assert lines[0] == "* 1 Section A" assert lines[1] == "" @@ -244,7 +244,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').text(encoding='utf8') + doc2 = (app.outdir / 'doc2.txt').read_text(encoding='utf8') expect = ( "2 Section B\n" "***********\n" @@ -261,7 +261,7 @@ def test_secnums(app, status, warning): app.config.text_add_secnumbers = False app.builder.build_all() - index = (app.outdir / 'index.txt').text(encoding='utf8') + index = (app.outdir / 'index.txt').read_text(encoding='utf8') lines = index.splitlines() assert lines[0] == "* Section A" assert lines[1] == "" @@ -270,7 +270,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').text(encoding='utf8') + doc2 = (app.outdir / 'doc2.txt').read_text(encoding='utf8') expect = ( "Section B\n" "*********\n" diff --git a/tests/test_correct_year.py b/tests/test_correct_year.py index cbba75946..7dc3ea89d 100644 --- a/tests/test_correct_year.py +++ b/tests/test_correct_year.py @@ -32,5 +32,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').text() + content = (app.outdir / 'index.html').read_text() assert expect_date in content diff --git a/tests/test_directive_code.py b/tests/test_directive_code.py index 7aeef81ec..eda331645 100644 --- a/tests/test_directive_code.py +++ b/tests/test_directive_code.py @@ -36,7 +36,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.text() + assert content == literal_inc_path.read_text() assert lines == 13 assert reader.lineno_start == 1 @@ -46,7 +46,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.text() + assert content == literal_inc_path.read_text() assert lines == 13 assert reader.lineno_start == 4 @@ -324,7 +324,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').text() + html = (app.outdir / 'caption.html').read_text() caption = ('<div class="code-block-caption">' '<span class="caption-number">Listing 1 </span>' '<span class="caption-text">caption <em>test</em> rb' @@ -336,7 +336,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').text() + latex = (app.outdir / 'python.tex').read_text() caption = '\\sphinxSetupCaptionForVerbatim{caption \\sphinxstyleemphasis{test} rb}' label = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:id1}}}' link = '\\hyperref[\\detokenize{caption:name-test-rb}]' \ @@ -349,7 +349,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').text() + latex = (app.outdir / 'python.tex').read_text() label1 = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:name-test-rb}}}' link1 = '\\hyperref[\\detokenize{caption:name-test-rb}]'\ '{\\sphinxcrossref{\\DUrole{std,std-ref}{Ruby}}' @@ -366,7 +366,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').text().replace('\r\n', '\n') + latex = (app.outdir / 'python.tex').read_text().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' @@ -379,7 +379,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').text() + literal_src = (app.srcdir / 'literal.inc').read_text() assert len(literal_include) > 0 actual = literal_include[0].text assert actual == literal_src @@ -412,7 +412,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').text() + html = (app.outdir / 'linenos.html').read_text() # :linenos: assert ('<td class="linenos"><div class="linenodiv"><pre>' @@ -458,7 +458,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').text().replace('\r\n', '\n') + latex = (app.outdir / 'python.tex').read_text().replace('\r\n', '\n') includes = ( '\\begin{sphinxVerbatim}' '[commandchars=\\\\\\{\\},numbers=left,firstnumber=1,stepnumber=1]\n' @@ -472,7 +472,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').text() + html = (app.outdir / 'caption.html').read_text() caption = ('<div class="code-block-caption">' '<span class="caption-number">Listing 2 </span>' '<span class="caption-text">caption <strong>test</strong> py' @@ -484,7 +484,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').text() + latex = (app.outdir / 'python.tex').read_text() caption = '\\sphinxSetupCaptionForVerbatim{caption \\sphinxstylestrong{test} py}' label = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:id2}}}' link = '\\hyperref[\\detokenize{caption:name-test-py}]' \ @@ -497,7 +497,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').text() + latex = (app.outdir / 'python.tex').read_text() label1 = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:name-test-py}}}' link1 = '\\hyperref[\\detokenize{caption:name-test-py}]'\ '{\\sphinxcrossref{\\DUrole{std,std-ref}{Python}}' @@ -584,7 +584,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').text() + html = (app.outdir / 'linenothreshold.html').read_text() lineos_head = '<td class="linenos"><div class="linenodiv"><pre>' lineos_tail = '</pre></div></td>' diff --git a/tests/test_domain_cpp.py b/tests/test_domain_cpp.py index 0956ab1a4..fba5fdb42 100644 --- a/tests/test_domain_cpp.py +++ b/tests/test_domain_cpp.py @@ -891,14 +891,14 @@ def test_build_domain_cpp_with_add_function_parentheses_is_True(app, status, war ] f = 'roles.html' - t = (app.outdir / f).text() + t = (app.outdir / f).read_text() for s in rolePatterns: check(s, t, f) for s in parenPatterns: check(s, t, f) f = 'any-role.html' - t = (app.outdir / f).text() + t = (app.outdir / f).read_text() for s in parenPatterns: check(s, t, f) @@ -934,14 +934,14 @@ def test_build_domain_cpp_with_add_function_parentheses_is_False(app, status, wa ] f = 'roles.html' - t = (app.outdir / f).text() + t = (app.outdir / f).read_text() for s in rolePatterns: check(s, t, f) for s in parenPatterns: check(s, t, f) f = 'any-role.html' - t = (app.outdir / f).text() + t = (app.outdir / f).read_text() for s in parenPatterns: check(s, t, f) @@ -951,7 +951,7 @@ def test_xref_consistency(app, status, warning): app.builder.build_all() test = 'xref_consistency.html' - output = (app.outdir / test).text() + output = (app.outdir / test).read_text() def classes(role, tag): pattern = (r'{role}-role:.*?' diff --git a/tests/test_domain_std.py b/tests/test_domain_std.py index 9d3e7f9c4..e98384824 100644 --- a/tests/test_domain_std.py +++ b/tests/test_domain_std.py @@ -371,5 +371,5 @@ def test_productionlist(app, status, warning): ('SecondLine', 'firstLineRule.html#grammar-token-_secondline', 'SecondLine'), ] - text = (app.outdir / 'LineContinuation.html').text() - assert "A</strong> ::= B C D E F G" in text
\ No newline at end of file + text = (app.outdir / 'LineContinuation.html').read_text() + assert "A</strong> ::= B C D E F G" in text diff --git a/tests/test_ext_apidoc.py b/tests/test_ext_apidoc.py index 3033cb450..a37527a02 100644 --- a/tests/test_ext_apidoc.py +++ b/tests/test_ext_apidoc.py @@ -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').text() + conf_py = (outdir / 'conf.py').read_text() 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').text() + assert ':private-members:' not in (tempdir / 'hello.rst').read_text() 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').text() + assert ':private-members:' in (tempdir / 'hello.rst').read_text() 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').text() + content = (outdir / 'modules.rst').read_text() 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').text() + content = (outdir / 'example.rst').read_text() 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').text() + content = (outdir / 'example.rst').read_text() 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').text() + content = (outdir / 'testpkg.rst').read_text() 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').text() + content = (outdir / 'testpkg.subpkg.rst').read_text() 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').text() + content = (outdir / 'testpkg.rst').read_text() assert content == ("testpkg package\n" "===============\n" "\n" @@ -557,7 +557,7 @@ def test_package_file_separate(tempdir): " :undoc-members:\n" " :show-inheritance:\n") - content = (outdir / 'testpkg.example.rst').text() + content = (outdir / 'testpkg.example.rst').read_text() assert content == ("testpkg.example module\n" "======================\n" "\n" @@ -574,7 +574,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').text() + content = (outdir / 'testpkg.rst').read_text() 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').text() + content = (outdir / 'testpkg.rst').read_text() 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').text() + content = (outdir / 'testpkg.rst').read_text() assert content == ("testpkg namespace\n" "=================\n" "\n" diff --git a/tests/test_ext_autodoc_configs.py b/tests/test_ext_autodoc_configs.py index bb4ad61b8..a9af8a272 100644 --- a/tests/test_ext_autodoc_configs.py +++ b/tests/test_ext_autodoc_configs.py @@ -544,7 +544,7 @@ def test_autodoc_typehints_none(app): 'autodoc_typehints': 'description'}) def test_autodoc_typehints_description(app): app.build() - context = (app.outdir / 'index.txt').text() + context = (app.outdir / 'index.txt').read_text() assert ('target.typehints.incr(a, b=1)\n' '\n' ' Parameters:\n' diff --git a/tests/test_ext_autosectionlabel.py b/tests/test_ext_autosectionlabel.py index 947be0e11..310435d8e 100644 --- a/tests/test_ext_autosectionlabel.py +++ b/tests/test_ext_autosectionlabel.py @@ -21,7 +21,7 @@ from sphinx.util import docutils def test_autosectionlabel_html(app, status, warning, skipped_labels=False): app.builder.build_all() - content = (app.outdir / 'index.html').text() + content = (app.outdir / 'index.html').read_text() 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) @@ -69,7 +69,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').text() + content = (app.outdir / 'index.html').read_text() # depth: 1 html = ('<li><p><a class="reference internal" href="#test-ext-autosectionlabel">' diff --git a/tests/test_ext_autosummary.py b/tests/test_ext_autosummary.py index ec9bbe11b..fe2a44034 100644 --- a/tests/test_ext_autosummary.py +++ b/tests/test_ext_autosummary.py @@ -210,13 +210,13 @@ def test_autosummary_generate(app, status, warning): assert doctree[3][0][0][2][2].astext() == 'autosummary_dummy_module.bar(x[, y])\n\n' assert doctree[3][0][0][2][3].astext() == 'autosummary_importfail\n\n' - module = (app.srcdir / 'generated' / 'autosummary_dummy_module.rst').text() + module = (app.srcdir / 'generated' / 'autosummary_dummy_module.rst').read_text() assert (' .. autosummary::\n' ' \n' ' Foo\n' ' \n' in module) - Foo = (app.srcdir / 'generated' / 'autosummary_dummy_module.Foo.rst').text() + Foo = (app.srcdir / 'generated' / 'autosummary_dummy_module.Foo.rst').read_text() assert '.. automethod:: __init__' in Foo assert (' .. autosummary::\n' ' \n' @@ -239,7 +239,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').text() + content = (srcdir / 'generated' / 'autosummary_dummy_module.rst').read_text() assert content == '' assert 'autosummary_dummy_module.rst' not in app._warning.getvalue() @@ -254,7 +254,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').text() + content = (srcdir / 'generated' / 'autosummary_dummy_module.rst').read_text() assert content != '' assert 'autosummary_dummy_module.rst' not in app._warning.getvalue() @@ -262,7 +262,7 @@ def test_autosummary_generate_overwrite2(app_params, make_app): @pytest.mark.sphinx('latex', **default_kw) def test_autosummary_latex_table_colspec(app, status, warning): app.builder.build_all() - result = (app.outdir / 'python.tex').text(encoding='utf8') + 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 @@ -312,7 +312,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').text() + module = (app.srcdir / 'generated' / 'autosummary_dummy_package.rst').read_text() assert (' .. autosummary::\n' ' \n' ' Bar\n' @@ -331,7 +331,7 @@ def test_generate_autosummary_docs_property(app): mock.return_value = [('target.methods.Base.prop', 'prop', None)] generate_autosummary_docs([], output_dir=app.srcdir, builder=app.builder, app=app) - content = (app.srcdir / 'target.methods.Base.prop.rst').text() + content = (app.srcdir / 'target.methods.Base.prop.rst').read_text() assert content == ("target.methods.Base.prop\n" "========================\n" "\n" @@ -344,7 +344,7 @@ def test_generate_autosummary_docs_property(app): def test_autosummary_skip_member(app): app.build() - content = (app.srcdir / 'generate' / 'target.Foo.rst').text() + content = (app.srcdir / 'generate' / 'target.Foo.rst').read_text() assert 'Foo.skipmeth' not in content assert 'Foo._privatemeth' in content diff --git a/tests/test_ext_coverage.py b/tests/test_ext_coverage.py index 87e5e4931..16f53112b 100644 --- a/tests/test_ext_coverage.py +++ b/tests/test_ext_coverage.py @@ -17,7 +17,7 @@ import pytest def test_build(app, status, warning): app.builder.build_all() - py_undoc = (app.outdir / 'python.txt').text() + py_undoc = (app.outdir / 'python.txt').read_text() assert py_undoc.startswith('Undocumented Python objects\n' '===========================\n') assert 'autodoc_target\n--------------\n' in py_undoc @@ -28,13 +28,13 @@ def test_build(app, status, warning): assert ' * mod -- No module named mod' # in the "failed import" section - c_undoc = (app.outdir / 'c.txt').text() + c_undoc = (app.outdir / 'c.txt').read_text() assert c_undoc.startswith('Undocumented C API elements\n' '===========================\n') assert 'api.h' in c_undoc assert ' * Py_SphinxTest' in c_undoc - undoc_py, undoc_c = pickle.loads((app.outdir / 'undoc.pickle').bytes()) + undoc_py, undoc_c = pickle.loads((app.outdir / 'undoc.pickle').read_bytes()) assert len(undoc_c) == 1 # the key is the full path to the header file, which isn't testable assert list(undoc_c.values())[0] == {('function', 'Py_SphinxTest')} @@ -50,7 +50,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').text() + actual = (app.outdir / 'python.txt').read_text() expected = '''Undocumented Python objects =========================== coverage_not_ignored diff --git a/tests/test_ext_githubpages.py b/tests/test_ext_githubpages.py index 8a8004347..41dbe4f60 100644 --- a/tests/test_ext_githubpages.py +++ b/tests/test_ext_githubpages.py @@ -31,4 +31,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').text() == 'sphinx-doc.org' + assert (app.outdir / 'CNAME').read_text() == 'sphinx-doc.org' diff --git a/tests/test_ext_graphviz.py b/tests/test_ext_graphviz.py index f89a96860..a8de950ce 100644 --- a/tests/test_ext_graphviz.py +++ b/tests/test_ext_graphviz.py @@ -20,7 +20,7 @@ from sphinx.ext.graphviz import ClickableMapDefinition def test_graphviz_png_html(app, status, warning): app.builder.build_all() - content = (app.outdir / 'index.html').text() + content = (app.outdir / 'index.html').read_text() html = (r'<div class="figure align-default" .*?>\s*' r'<div class="graphviz"><img .*?/></div>\s*<p class="caption">' r'<span class="caption-text">caption of graph</span>.*</p>\s*</div>') @@ -51,7 +51,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').text() + content = (app.outdir / 'index.html').read_text() html = (r'<div class=\"figure align-default\" .*?>\n' r'<div class="graphviz"><object data=\".*\.svg\".*>\n' @@ -91,7 +91,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').text() + content = (app.outdir / 'python.tex').read_text() macro = ('\\\\begin{figure}\\[htbp\\]\n\\\\centering\n\\\\capstart\n\n' '\\\\sphinxincludegraphics\\[\\]{graphviz-\\w+.pdf}\n' '\\\\caption{caption of graph}\\\\label{.*}\\\\end{figure}') @@ -117,7 +117,7 @@ def test_graphviz_latex(app, status, warning): def test_graphviz_i18n(app, status, warning): app.builder.build_all() - content = (app.outdir / 'index.html').text() + content = (app.outdir / 'index.html').read_text() html = '<img src=".*?" alt="digraph {\n BAR -> BAZ\n}" class="graphviz" />' assert re.search(html, content, re.M) diff --git a/tests/test_ext_ifconfig.py b/tests/test_ext_ifconfig.py index abce1d025..232ddf0d8 100644 --- a/tests/test_ext_ifconfig.py +++ b/tests/test_ext_ifconfig.py @@ -14,6 +14,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').text() + result = (app.outdir / 'index.txt').read_text() assert 'spam' in result assert 'ham' not in result diff --git a/tests/test_ext_imgconverter.py b/tests/test_ext_imgconverter.py index 232808270..075446b0a 100644 --- a/tests/test_ext_imgconverter.py +++ b/tests/test_ext_imgconverter.py @@ -18,7 +18,7 @@ import pytest def test_ext_imgconverter(app, status, warning): app.builder.build_all() - content = (app.outdir / 'python.tex').text() + content = (app.outdir / 'python.tex').read_text() assert '\\sphinxincludegraphics{{svgimg}.png}' in content assert not (app.outdir / 'svgimg.svg').exists() assert (app.outdir / 'svgimg.png').exists() diff --git a/tests/test_ext_inheritance_diagram.py b/tests/test_ext_inheritance_diagram.py index c1cf4524d..baeaa401e 100644 --- a/tests/test_ext_inheritance_diagram.py +++ b/tests/test_ext_inheritance_diagram.py @@ -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').text() + content = (app.outdir / 'index.html').read_text() pattern = ('<div class="figure align-default" id="id1">\n' '<div class="graphviz">' @@ -155,7 +155,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').text() + content = (app.outdir / 'index.html').read_text() pattern = ('<div class="figure align-default" id="id1">\n' '<div class="graphviz">' @@ -173,7 +173,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').text() + content = (app.outdir / 'python.tex').read_text() pattern = ('\\\\begin{figure}\\[htbp]\n\\\\centering\n\\\\capstart\n\n' '\\\\sphinxincludegraphics\\[\\]{inheritance-\\w+.pdf}\n' @@ -195,7 +195,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').text() + content = (app.outdir / 'index.html').read_text() pattern = ('<div class="figure align-default" id="id1">\n' '<div class="graphviz">' diff --git a/tests/test_ext_intersphinx.py b/tests/test_ext_intersphinx.py index ba377f2a0..9f0f18663 100644 --- a/tests/test_ext_intersphinx.py +++ b/tests/test_ext_intersphinx.py @@ -236,7 +236,7 @@ def test_missing_reference_cppdomain(tempdir, app, status, warning): load_mappings(app) app.build() - html = (app.outdir / 'index.html').text() + html = (app.outdir / 'index.html').read_text() assert ('<a class="reference external"' ' href="https://docs.python.org/index.html#cpp_foo_bar"' ' title="(in foo v2.0)">' diff --git a/tests/test_ext_math.py b/tests/test_ext_math.py index 256236489..b5de6cc1c 100644 --- a/tests/test_ext_math.py +++ b/tests/test_ext_math.py @@ -39,7 +39,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').text() + content = (app.outdir / 'index.html').read_text() 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) @@ -57,7 +57,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').text() + content = (app.outdir / 'index.html').read_text() 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) @@ -69,7 +69,7 @@ def test_imgmath_svg(app, status, warning): def test_mathjax_options(app, status, warning): app.builder.build_all() - content = (app.outdir / 'index.html').text() + content = (app.outdir / 'index.html').read_text() assert ('<script async="async" integrity="sha384-0123456789" ' 'src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?' 'config=TeX-AMS-MML_HTMLorMML"></script>' in content) @@ -80,7 +80,7 @@ def test_mathjax_options(app, status, warning): def test_mathjax_align(app, status, warning): app.builder.build_all() - content = (app.outdir / 'index.html').text() + content = (app.outdir / 'index.html').read_text() 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>') @@ -93,7 +93,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').text() + content = (app.outdir / 'index.html').read_text() 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) @@ -104,7 +104,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').text() + content = (app.outdir / 'python.tex').read_text() macro = (r'\\begin{equation\*}\s*' r'\\begin{split}a\^2\+b\^2=c\^2\\end{split}\s*' r'\\end{equation\*}') @@ -134,7 +134,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').text() + content = (app.outdir / 'math.html').read_text() 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>') @@ -147,7 +147,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').text() + content = (app.outdir / 'python.tex').read_text() macro = (r'Referencing equation Eq.\\ref{equation:math:foo} and ' r'Eq.\\ref{equation:math:foo}.') assert re.search(macro, content, re.S) @@ -160,7 +160,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').text() + content = (app.outdir / 'math.html').read_text() html = ('<div class="math notranslate nohighlight" id="equation-math-0">\n' '<span class="eqno">(1.2)') assert html in content @@ -178,7 +178,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').text() + content = (app.outdir / 'page.html').read_text() html = '<span class="eqno">(3)<a class="headerlink" href="#equation-bar"' assert html in content html = ('<p>Referencing equations <a class="reference internal" ' @@ -218,7 +218,7 @@ def test_math_compat(app, status, warning): def test_mathjax_config(app, status, warning): app.builder.build_all() - content = (app.outdir / 'index.html').text() + content = (app.outdir / 'index.html').read_text() assert ('<script type="text/x-mathjax-config">' 'MathJax.Hub.Config({"extensions": ["tex2jax.js"]})' '</script>' in content) @@ -229,5 +229,5 @@ def test_mathjax_config(app, status, warning): def test_mathjax_is_not_installed_if_no_equations(app, status, warning): app.builder.build_all() - content = (app.outdir / 'index.html').text() + content = (app.outdir / 'index.html').read_text() assert 'MathJax.js' not in content diff --git a/tests/test_ext_todo.py b/tests/test_ext_todo.py index 8c00ef088..7b4fdeabe 100644 --- a/tests/test_ext_todo.py +++ b/tests/test_ext_todo.py @@ -29,7 +29,7 @@ def test_todo(app, status, warning): app.builder.build_all() # check todolist - content = (app.outdir / 'index.html').text() + content = (app.outdir / 'index.html').read_text() assert ('<p class="admonition-title">Todo</p>\n' '<p>todo in foo</p>') in content @@ -37,7 +37,7 @@ def test_todo(app, status, warning): '<p>todo in bar</p>') in content # check todo - content = (app.outdir / 'foo.html').text() + content = (app.outdir / 'foo.html').read_text() assert ('<p class="admonition-title">Todo</p>\n' '<p>todo in foo</p>') in content @@ -67,7 +67,7 @@ def test_todo_not_included(app, status, warning): app.builder.build_all() # check todolist - content = (app.outdir / 'index.html').text() + content = (app.outdir / 'index.html').read_text() assert ('<p class="admonition-title">Todo</p>\n' '<p>todo in foo</p>') not in content @@ -75,7 +75,7 @@ def test_todo_not_included(app, status, warning): '<p>todo in bar</p>') not in content # check todo - content = (app.outdir / 'foo.html').text() + content = (app.outdir / 'foo.html').read_text() assert ('<p class="admonition-title">Todo</p>\n' '<p>todo in foo</p>') not in content @@ -102,7 +102,7 @@ def test_todo_valid_link(app, status, warning): # Ensure the LaTeX output is built. app.builder.build_all() - content = (app.outdir / 'python.tex').text() + content = (app.outdir / 'python.tex').read_text() # 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 diff --git a/tests/test_ext_viewcode.py b/tests/test_ext_viewcode.py index 2540d09ea..3d9ea27d7 100644 --- a/tests/test_ext_viewcode.py +++ b/tests/test_ext_viewcode.py @@ -24,7 +24,7 @@ def test_viewcode(app, status, warning): warnings ) - result = (app.outdir / 'index.html').text() + result = (app.outdir / 'index.html').read_text() 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 @@ -37,7 +37,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').text() + result = (app.outdir / '_modules/spam/mod1.html').read_text() 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>' @@ -53,7 +53,7 @@ def test_viewcode(app, status, warning): def test_linkcode(app, status, warning): app.builder.build(['objects']) - stuff = (app.outdir / 'objects.html').text() + stuff = (app.outdir / 'objects.html').read_text() assert 'http://foobar/source/foolib.py' in stuff assert 'http://foobar/js/' in stuff @@ -65,7 +65,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').text() + source = (app.srcdir / 'not_a_package/__init__.py').read_text() tags = { 'func1': ('def', 1, 1), 'Class1': ('class', 1, 1), @@ -73,7 +73,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').text() + source = (app.srcdir / 'not_a_package/submodule.py').read_text() tags = { 'not_a_package.submodule.func1': ('def', 11, 15), 'Class1': ('class', 19, 22), @@ -93,7 +93,7 @@ def test_local_source_files(app, status, warning): warnings ) - result = (app.outdir / 'index.html').text() + result = (app.outdir / 'index.html').read_text() 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 diff --git a/tests/test_intl.py b/tests/test_intl.py index f038c2b28..0e7dd4f62 100644 --- a/tests/test_intl.py +++ b/tests/test_intl.py @@ -95,7 +95,7 @@ def assert_count(expected_expr, result, count): @pytest.mark.test_params(shared_result='test_intl_basic') def test_text_toctree(app): app.build() - result = (app.outdir / 'index.txt').text() + result = (app.outdir / 'index.txt').read_text() assert_startswith(result, "CONTENTS\n********\n\nTABLE OF CONTENTS\n") @@ -117,7 +117,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').text() + result = (app.outdir / 'warnings.txt').read_text() expect = ("3. I18N WITH REST WARNINGS" "\n**************************\n" "\nLINE OF >>``<<BROKEN LITERAL MARKUP.\n") @@ -131,7 +131,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').text() + result = (app.outdir / 'bom.txt').read_text() expect = ("2. Datei mit UTF-8" "\n******************\n" # underline matches new translation "\nThis file has umlauts: äöü.\n") @@ -144,7 +144,7 @@ def test_text_title_underline(app): def test_text_subdirs(app): app.build() # --- check translation in subdirs - result = (app.outdir / 'subdir' / 'index.txt').text() + result = (app.outdir / 'subdir' / 'index.txt').read_text() assert_startswith(result, "1. subdir contents\n******************\n") @@ -154,7 +154,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').text() + result = (app.outdir / 'refs_inconsistency.txt').read_text() expect = ("8. I18N WITH REFS INCONSISTENCY" "\n*******************************\n" "\n* FOR CITATION [ref3].\n" @@ -204,7 +204,7 @@ def test_text_inconsistency_warnings(app, warning): def test_text_literalblock_warnings(app, warning): app.build() # --- check warning for literal block - result = (app.outdir / 'literalblock.txt').text() + result = (app.outdir / 'literalblock.txt').read_text() expect = ("9. I18N WITH LITERAL BLOCK" "\n**************************\n" "\nCORRECT LITERAL BLOCK:\n" @@ -226,7 +226,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').text() + result = (app.outdir / 'definition_terms.txt').read_text() expect = ("13. I18N WITH DEFINITION TERMS" "\n******************************\n" "\nSOME TERM" @@ -246,7 +246,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').text() + result = (app.outdir / 'glossary_terms.txt').read_text() expect = ("18. I18N WITH GLOSSARY TERMS" "\n****************************\n" "\nSOME NEW TERM" @@ -265,7 +265,7 @@ def test_text_glossary_term(app, warning): def test_text_glossary_term_inconsistencies(app, warning): app.build() # --- glossary term inconsistencies: regression test for #1090 - result = (app.outdir / 'glossary_terms_inconsistency.txt').text() + result = (app.outdir / 'glossary_terms_inconsistency.txt').read_text() expect = ("19. I18N WITH GLOSSARY TERMS INCONSISTENCY" "\n******************************************\n" "\n1. LINK TO *SOME NEW TERM*.\n") @@ -298,7 +298,7 @@ def test_gettext_section(app): def test_text_section(app): app.build() # --- section - result = (app.outdir / 'section.txt').text() + result = (app.outdir / 'section.txt').read_text() 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 @@ -310,7 +310,7 @@ def test_text_section(app): def test_text_seealso(app): app.build() # --- seealso - result = (app.outdir / 'seealso.txt').text() + result = (app.outdir / 'seealso.txt').read_text() expect = ("12. I18N WITH SEEALSO" "\n*********************\n" "\nSee also: SHORT TEXT 1\n" @@ -327,7 +327,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').text() + result = (app.outdir / 'figure.txt').read_text() expect = ("14. I18N WITH FIGURE CAPTION" "\n****************************\n" "\n [image]MY CAPTION OF THE FIGURE\n" @@ -371,7 +371,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').text() + result = (app.outdir / 'rubric.txt').read_text() expect = ("I18N WITH RUBRIC" "\n****************\n" "\n-[ RUBRIC TITLE ]-\n" @@ -389,7 +389,7 @@ def test_text_rubric(app): def test_text_docfields(app): app.build() # --- docfields - result = (app.outdir / 'docfields.txt').text() + result = (app.outdir / 'docfields.txt').read_text() expect = ("21. I18N WITH DOCFIELDS" "\n***********************\n" "\nclass Cls1\n" @@ -420,7 +420,7 @@ def test_text_admonitions(app): # --- admonitions # #1206: gettext did not translate admonition directive's title # seealso: http://docutils.sourceforge.net/docs/ref/rst/directives.html#admonitions - result = (app.outdir / 'admonitions.txt').text() + result = (app.outdir / 'admonitions.txt').read_text() directives = ( "attention", "caution", "danger", "error", "hint", "important", "note", "tip", "warning", "admonition") @@ -462,7 +462,7 @@ def test_gettext_table(app): def test_text_table(app): app.build() # --- toctree - result = (app.outdir / 'table.txt').text() + result = (app.outdir / 'table.txt').read_text() 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 @@ -486,7 +486,7 @@ def test_gettext_toctree(app): def test_text_toctree(app): app.build() # --- toctree - result = (app.outdir / 'toctree.txt').text() + result = (app.outdir / 'toctree.txt').read_text() 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 @@ -510,7 +510,7 @@ def test_gettext_topic(app): def test_text_topic(app): app.build() # --- topic - result = (app.outdir / 'topic.txt').text() + result = (app.outdir / 'topic.txt').read_text() 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 @@ -628,7 +628,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').text() + result = (app.outdir / 'index.html').read_text() expected_expr = '<meta content="TESTDATA FOR I18N" name="description" />' assert expected_expr in result expected_expr = '<meta content="I18N, SPHINX, MARKUP" name="keywords" />' @@ -644,7 +644,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').text() + (app.outdir / 'footnote.html').read_text() @sphinx_intl @@ -653,7 +653,7 @@ def test_html_footnotes(app): def test_html_undefined_refs(app): app.build() # --- links to undefined reference - result = (app.outdir / 'refs_inconsistency.html').text() + result = (app.outdir / 'refs_inconsistency.html').read_text() expected_expr = ('<a class="reference external" ' 'href="http://www.example.com">reference</a>') @@ -675,7 +675,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').text() + result = (app.outdir / 'genindex.html').read_text() def wrap(tag, keyword): start_tag = "<%s[^>]*>" % tag @@ -713,7 +713,7 @@ def test_html_index_entries(app): def test_html_versionchanges(app): app.build() # --- versionchanges - result = (app.outdir / 'versionchange.html').text() + result = (app.outdir / 'versionchange.html').read_text() def get_content(result, name): matched = re.search(r'<div class="%s">\n*(.*?)</div>' % name, @@ -750,7 +750,7 @@ def test_html_docfields(app): app.build() # --- docfields # expect no error by build - (app.outdir / 'docfields.html').text() + (app.outdir / 'docfields.html').read_text() @sphinx_intl @@ -759,7 +759,7 @@ def test_html_docfields(app): def test_html_template(app): app.build() # --- gettext template - result = (app.outdir / 'contents.html').text() + result = (app.outdir / 'contents.html').read_text() assert "WELCOME" in result assert "SPHINX 2013.120" in result @@ -1056,7 +1056,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').text() + result = (app.outdir / 'literalblock.html').read_text() # title should be translated expected_expr = 'CODE-BLOCKS' @@ -1092,7 +1092,7 @@ def test_additional_targets_should_not_be_translated(app): # [raw.txt] - result = (app.outdir / 'raw.html').text() + result = (app.outdir / 'raw.html').read_text() # raw block should not be translated expected_expr = """<iframe src="http://sphinx-doc.org"></iframe></div>""" @@ -1100,7 +1100,7 @@ def test_additional_targets_should_not_be_translated(app): # [figure.txt] - result = (app.outdir / 'figure.html').text() + result = (app.outdir / 'figure.html').read_text() # alt and src for image block should not be translated expected_expr = """<img alt="i18n" src="_images/i18n.png" />""" @@ -1130,7 +1130,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').text() + result = (app.outdir / 'literalblock.html').read_text() # title should be translated expected_expr = 'CODE-BLOCKS' @@ -1166,7 +1166,7 @@ def test_additional_targets_should_be_translated(app): # [raw.txt] - result = (app.outdir / 'raw.html').text() + result = (app.outdir / 'raw.html').read_text() # raw block should be translated expected_expr = """<iframe src="HTTP://SPHINX-DOC.ORG"></iframe></div>""" @@ -1174,7 +1174,7 @@ def test_additional_targets_should_be_translated(app): # [figure.txt] - result = (app.outdir / 'figure.html').text() + result = (app.outdir / 'figure.html').read_text() # alt and src for image block should be translated expected_expr = """<img alt="I18N -> IMG" src="_images/img.png" />""" diff --git a/tests/test_quickstart.py b/tests/test_quickstart.py index 70a6f030e..bdd7073d1 100644 --- a/tests/test_quickstart.py +++ b/tests/test_quickstart.py @@ -193,7 +193,7 @@ def test_generated_files_eol(tempdir): qs.generate(d) def assert_eol(filename, eol): - content = filename.bytes().decode() + content = filename.read_bytes().decode() assert all([l[-len(eol):] == eol for l in content.splitlines(True)]) assert_eol(tempdir / 'make.bat', '\r\n') diff --git a/tests/test_search.py b/tests/test_search.py index 802602d5f..60631f7a4 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -41,7 +41,7 @@ def setup_module(): def jsload(path): - searchindex = path.text() + searchindex = path.read_text() assert searchindex.startswith('Search.setIndex(') assert searchindex.endswith(')') @@ -98,7 +98,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').text() + searchindex = (app.outdir / 'searchindex.js').read_text() assert 'zfs' in searchindex @@ -112,7 +112,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').text() + searchindex = (app.outdir / 'searchindex.js').read_text() # 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 @@ -247,7 +247,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').text() + searchindex = (app.outdir / 'searchindex.js').read_text() assert 'chinesetest ' not in searchindex assert 'chinesetest' in searchindex assert 'chinesetesttwo' in searchindex diff --git a/tests/test_setup_command.py b/tests/test_setup_command.py index 9bfc08d06..14a687ada 100644 --- a/tests/test_setup_command.py +++ b/tests/test_setup_command.py @@ -94,7 +94,7 @@ def nonascii_srcdir(request, setup_command): """)) master_doc = srcdir / 'index.txt' - master_doc.write_bytes((master_doc.text() + dedent(""" + master_doc.write_bytes((master_doc.read_text() + dedent(""" .. toctree:: %(mb_name)s/%(mb_name)s diff --git a/tests/test_smartquotes.py b/tests/test_smartquotes.py index 50a1cf52e..6276e6a74 100644 --- a/tests/test_smartquotes.py +++ b/tests/test_smartquotes.py @@ -17,7 +17,7 @@ from sphinx.util import docutils def test_basic(app, status, warning): app.build() - content = (app.outdir / 'index.html').text() + content = (app.outdir / 'index.html').read_text() assert '<p>– “Sphinx” is a tool that makes it easy …</p>' in content @@ -25,7 +25,7 @@ def test_basic(app, status, warning): def test_text_builder(app, status, warning): app.build() - content = (app.outdir / 'index.txt').text() + content = (app.outdir / 'index.txt').read_text() assert '-- "Sphinx" is a tool that makes it easy ...' in content @@ -33,7 +33,7 @@ def test_text_builder(app, status, warning): def test_man_builder(app, status, warning): app.build() - content = (app.outdir / 'python.1').text() + content = (app.outdir / 'python.1').read_text() assert '\\-\\- "Sphinx" is a tool that makes it easy ...' in content @@ -41,7 +41,7 @@ def test_man_builder(app, status, warning): def test_latex_builder(app, status, warning): app.build() - content = (app.outdir / 'python.tex').text() + content = (app.outdir / 'python.tex').read_text() assert '\\textendash{} “Sphinx” is a tool that makes it easy …' in content @@ -50,7 +50,7 @@ def test_latex_builder(app, status, warning): def test_ja_html_builder(app, status, warning): app.build() - content = (app.outdir / 'index.html').text() + content = (app.outdir / 'index.html').read_text() assert '<p>-- "Sphinx" is a tool that makes it easy ...</p>' in content @@ -59,7 +59,7 @@ def test_ja_html_builder(app, status, warning): def test_smartquotes_disabled(app, status, warning): app.build() - content = (app.outdir / 'index.html').text() + content = (app.outdir / 'index.html').read_text() assert '<p>-- "Sphinx" is a tool that makes it easy ...</p>' in content @@ -70,7 +70,7 @@ def test_smartquotes_disabled(app, status, warning): def test_smartquotes_action(app, status, warning): app.build() - content = (app.outdir / 'index.html').text() + content = (app.outdir / 'index.html').read_text() assert '<p>-- “Sphinx” is a tool that makes it easy ...</p>' in content @@ -79,7 +79,7 @@ def test_smartquotes_action(app, status, warning): def test_smartquotes_excludes_language(app, status, warning): app.build() - content = (app.outdir / 'index.html').text() + content = (app.outdir / 'index.html').read_text() assert '<p>– 「Sphinx」 is a tool that makes it easy …</p>' in content @@ -88,5 +88,5 @@ def test_smartquotes_excludes_language(app, status, warning): def test_smartquotes_excludes_builders(app, status, warning): app.build() - content = (app.outdir / 'python.1').text() + content = (app.outdir / 'python.1').read_text() assert '– “Sphinx” is a tool that makes it easy …' in content diff --git a/tests/test_templating.py b/tests/test_templating.py index 0be960b88..becacda0d 100644 --- a/tests/test_templating.py +++ b/tests/test_templating.py @@ -20,7 +20,7 @@ def test_layout_overloading(make_app, app_params): setup_documenters(app) app.builder.build_update() - result = (app.outdir / 'index.html').text() + result = (app.outdir / 'index.html').read_text() assert '<!-- layout overloading -->' in result @@ -31,5 +31,5 @@ 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').text() + result = (app.outdir / 'generated' / 'sphinx.application.TemplateBridge.html').read_text() assert 'autosummary/class.rst method block overloading' in result diff --git a/tests/test_theming.py b/tests/test_theming.py index d154d8a4c..d8342c10b 100644 --- a/tests/test_theming.py +++ b/tests/test_theming.py @@ -76,16 +76,16 @@ def test_js_source(app, status, warning): v = '3.4.1' msg = 'jquery.js version does not match to {v}'.format(v=v) - jquery_min = (app.outdir / '_static' / 'jquery.js').text() + jquery_min = (app.outdir / '_static' / 'jquery.js').read_text() assert 'jQuery v{v}'.format(v=v) in jquery_min, msg - jquery_src = (app.outdir / '_static' / 'jquery-{v}.js'.format(v=v)).text() + jquery_src = (app.outdir / '_static' / 'jquery-{v}.js'.format(v=v)).read_text() assert 'jQuery JavaScript Library v{v}'.format(v=v) in jquery_src, msg v = '1.3.1' msg = 'underscore.js version does not match to {v}'.format(v=v) - underscore_min = (app.outdir / '_static' / 'underscore.js').text() + underscore_min = (app.outdir / '_static' / 'underscore.js').read_text() assert 'Underscore.js {v}'.format(v=v) in underscore_min, msg - underscore_src = (app.outdir / '_static' / 'underscore-{v}.js'.format(v=v)).text() + underscore_src = (app.outdir / '_static' / 'underscore-{v}.js'.format(v=v)).read_text() assert 'Underscore.js {v}'.format(v=v) in underscore_src, msg @@ -108,12 +108,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').text() == ( + assert (app.outdir / '_static' / 'statictmpl.html').read_text() == ( '<!-- testing static templates -->\n' '<html><project>Python</project></html>' ) - result = (app.outdir / 'index.html').text() + result = (app.outdir / 'index.html').read_text() assert '<meta name="testopt" content="optdefault" />' in result @@ -122,7 +122,7 @@ def test_theme_sidebars(app, status, warning): app.build() # test-theme specifies globaltoc and searchbox as default sidebars - result = (app.outdir / 'index.html').text(encoding='utf8') + 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 diff --git a/tests/test_toctree.py b/tests/test_toctree.py index c4d0c9b7b..38886769a 100644 --- a/tests/test_toctree.py +++ b/tests/test_toctree.py @@ -41,7 +41,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').text() + index = (app.srcdir / 'index.rst').read_text() index = re.sub(':numbered:.*', ':numbered: 1', index) (app.srcdir / 'index.rst').write_text(index) app.builder.build_all() diff --git a/tests/test_transforms_post_transforms_code.py b/tests/test_transforms_post_transforms_code.py index bd66a4c91..51258f14e 100644 --- a/tests/test_transforms_post_transforms_code.py +++ b/tests/test_transforms_post_transforms_code.py @@ -13,7 +13,7 @@ import pytest def test_trim_doctest_flags_html(app, status, warning): app.build() - result = (app.outdir / 'index.html').text(encoding='utf8') + result = (app.outdir / 'index.html').read_text(encoding='utf8') assert 'FOO' not in result assert 'BAR' in result assert 'BAZ' not in result @@ -25,7 +25,7 @@ def test_trim_doctest_flags_html(app, status, warning): def test_trim_doctest_flags_latex(app, status, warning): app.build() - result = (app.outdir / 'python.tex').text(encoding='utf8') + result = (app.outdir / 'python.tex').read_text(encoding='utf8') assert 'FOO' not in result assert 'BAR' in result assert 'BAZ' not in result diff --git a/tests/test_util_fileutil.py b/tests/test_util_fileutil.py index 02d1acada..e9c80d5b6 100644 --- a/tests/test_util_fileutil.py +++ b/tests/test_util_fileutil.py @@ -33,7 +33,7 @@ def test_copy_asset_file(tempdir): copy_asset_file(src, dest) assert dest.exists() - assert src.text() == dest.text() + assert src.read_text() == dest.read_text() # copy template file src = (tempdir / 'asset.txt_t') @@ -43,7 +43,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').text() == '# template data' + assert (tempdir / 'output.txt').read_text() == '# template data' # copy template file to subdir src = (tempdir / 'asset.txt_t') @@ -53,7 +53,7 @@ def test_copy_asset_file(tempdir): copy_asset_file(src, subdir1, {'var1': 'template'}, renderer) assert (subdir1 / 'asset.txt').exists() - assert (subdir1 / 'asset.txt').text() == '# template data' + assert (subdir1 / 'asset.txt').read_text() == '# template data' # copy template file without context src = (tempdir / 'asset.txt_t') @@ -63,7 +63,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').text() == '# {{var1}} data' + assert (subdir2 / 'asset.txt_t').read_text() == '# {{var1}} data' def test_copy_asset(tempdir): @@ -91,11 +91,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').text() == 'bar.rst' + assert (destdir / 'foo.rst').read_text() == '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').text() == 'sidebar: baz' + assert (destdir / '_templates' / 'sidebar.html').read_text() == 'sidebar: baz' # copy with exclusion def excluded(path): |