mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Specify encoding to avoid EncodingWarning
This commit is contained in:
parent
b0485f9323
commit
a4102a7507
@ -6,14 +6,14 @@ from sphinx.util.fileutil import copy_asset
|
||||
def _copy_asset_overwrite_hook(app):
|
||||
css = app.outdir / '_static' / 'custom-styles.css'
|
||||
# html_static_path is copied by default
|
||||
assert css.read_text() == '/* html_static_path */\n', 'invalid default text'
|
||||
assert css.read_text(encoding='utf-8') == '/* html_static_path */\n', 'invalid default text'
|
||||
# warning generated by here
|
||||
copy_asset(
|
||||
Path(__file__).parent.joinpath('myext_static', 'custom-styles.css'),
|
||||
app.outdir / '_static',
|
||||
)
|
||||
# This demonstrates that no overwriting occurs
|
||||
assert css.read_text() == '/* html_static_path */\n', 'file overwritten!'
|
||||
assert css.read_text(encoding='utf-8') == '/* html_static_path */\n', 'file overwritten!'
|
||||
return []
|
||||
|
||||
|
||||
|
@ -240,6 +240,7 @@ def test_raw_node(app: SphinxTestApp) -> None:
|
||||
index.write_text(
|
||||
".. raw:: 'html'\n"
|
||||
" :url: http://{address}/".format(address=address),
|
||||
encoding='utf-8',
|
||||
)
|
||||
app.build()
|
||||
|
||||
|
@ -696,7 +696,7 @@ def test_autogen(rootdir, tmp_path):
|
||||
|
||||
def test_autogen_remove_old(rootdir, tmp_path):
|
||||
"""Test the ``--remove-old`` option."""
|
||||
tmp_path.joinpath('other.rst').write_text('old content')
|
||||
tmp_path.joinpath('other.rst').write_text('old content', encoding='utf-8')
|
||||
with chdir(rootdir / 'test-templating'):
|
||||
args = ['-o', str(tmp_path), '-t', '.', 'autosummary_templating.txt']
|
||||
autogen_main(args)
|
||||
|
Loading…
Reference in New Issue
Block a user