|
11 | 11 | from html5lib import HTMLParser
|
12 | 12 |
|
13 | 13 | import sphinx.builders.html
|
14 |
| -from sphinx.builders.html import validate_html_extra_path, validate_html_static_path |
15 |
| -from sphinx.errors import ConfigError |
| 14 | +from sphinx.builders.html import ( |
| 15 | + _file_checksum, |
| 16 | + validate_html_extra_path, |
| 17 | + validate_html_static_path, |
| 18 | +) |
| 19 | +from sphinx.errors import ConfigError, ThemeError |
16 | 20 | from sphinx.testing.util import strip_escseq
|
17 | 21 | from sphinx.util.inventory import InventoryFile
|
18 | 22 |
|
@@ -1242,6 +1246,20 @@ def test_file_checksum(app):
|
1242 | 1246 | assert '<script src="https://example.com/script.js"></script>' in content
|
1243 | 1247 |
|
1244 | 1248 |
|
| 1249 | +def test_file_checksum_query_string(): |
| 1250 | + with pytest.raises(ThemeError, match='Local asset file paths must not contain query strings'): |
| 1251 | + _file_checksum('', 'with_query_string.css?dead_parrots=1') |
| 1252 | + |
| 1253 | + with pytest.raises(ThemeError, match='Local asset file paths must not contain query strings'): |
| 1254 | + _file_checksum('', 'with_query_string.js?dead_parrots=1') |
| 1255 | + |
| 1256 | + with pytest.raises(ThemeError, match='Local asset file paths must not contain query strings'): |
| 1257 | + _file_checksum(Path.cwd(), '_static/with_query_string.css?dead_parrots=1') |
| 1258 | + |
| 1259 | + with pytest.raises(ThemeError, match='Local asset file paths must not contain query strings'): |
| 1260 | + _file_checksum(Path.cwd(), '_static/with_query_string.js?dead_parrots=1') |
| 1261 | + |
| 1262 | + |
1245 | 1263 | @pytest.mark.sphinx('html', testroot='html_assets')
|
1246 | 1264 | def test_javscript_loading_method(app):
|
1247 | 1265 | app.add_js_file('normal.js')
|
|
0 commit comments