From 8cd677f92935b49506f56a6f2b9fbf1d59c1d4ad Mon Sep 17 00:00:00 2001
From: Adam Turner <9087854+aa-turner@users.noreply.github.com>
Date: Mon, 7 Aug 2023 21:51:25 +0100
Subject: [PATCH] Add a new test for ``_file_checksum``
---
tests/test_build_html.py | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/tests/test_build_html.py b/tests/test_build_html.py
index 5a10c964a..67e57ec79 100644
--- a/tests/test_build_html.py
+++ b/tests/test_build_html.py
@@ -1217,6 +1217,31 @@ def test_assets_order(app, monkeypatch):
assert re.search(pattern, content, re.DOTALL), content
+@pytest.mark.sphinx('html', testroot='html_file_checksum')
+def test_file_checksum(app):
+ app.add_css_file('stylesheet-a.css')
+ app.add_css_file('stylesheet-b.css')
+ app.add_css_file('https://example.com/custom.css')
+ app.add_js_file('script.js')
+ app.add_js_file('empty.js')
+ app.add_js_file('https://example.com/script.js')
+
+ app.builder.build_all()
+ content = (app.outdir / 'index.html').read_text(encoding='utf8')
+
+ # checksum for local files
+ assert '' in content
+ assert '' in content
+ assert '' in content
+
+ # empty files have no checksum
+ assert '' in content
+
+ # no checksum for hyperlinks
+ assert '' in content
+ assert '' in content
+
+
@pytest.mark.sphinx('html', testroot='html_assets')
def test_javscript_loading_method(app):
app.add_js_file('normal.js')