mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Warn when files are overwritten in the build directory (#12612)
This commit is contained in:
@@ -2,7 +2,10 @@
|
||||
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
from sphinx.jinja2glue import BuiltinTemplateLoader
|
||||
from sphinx.util import strip_colors
|
||||
from sphinx.util.fileutil import _template_basename, copy_asset, copy_asset_file
|
||||
|
||||
|
||||
@@ -103,6 +106,20 @@ def test_copy_asset(tmp_path):
|
||||
assert not (destdir / '_templates' / 'sidebar.html').exists()
|
||||
|
||||
|
||||
@pytest.mark.xfail(reason='Filesystem chicanery(?)')
|
||||
@pytest.mark.sphinx('html', testroot='util-copyasset_overwrite')
|
||||
def test_copy_asset_overwrite(app):
|
||||
app.build()
|
||||
warnings = strip_colors(app.warning.getvalue())
|
||||
src = app.srcdir / 'myext_static' / 'custom-styles.css'
|
||||
dst = app.outdir / '_static' / 'custom-styles.css'
|
||||
assert warnings == (
|
||||
f'WARNING: Copying the source path {src} to {dst} will overwrite data, '
|
||||
'as a file already exists at the destination path '
|
||||
'and the content does not match.\n'
|
||||
)
|
||||
|
||||
|
||||
def test_template_basename():
|
||||
assert _template_basename('asset.txt') is None
|
||||
assert _template_basename('asset.txt.jinja') == 'asset.txt'
|
||||
|
||||
Reference in New Issue
Block a user