mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-09-03 20:52:55 -05:00
test: Use read_text() and read_bytes()
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user