Skip to content

Commit 7278043

Browse files
Avoid storing build time in gzip headers (#13)
Co-authored-by: James Addison <[email protected]>
1 parent 6c87f73 commit 7278043

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

sphinxcontrib/devhelp/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def write_index(title: str, refs: list[Any], subitems: Any) -> None:
124124

125125
# Dump the XML file
126126
xmlfile = path.join(outdir, outname + '.devhelp.gz')
127-
with gzip.open(xmlfile, 'w') as f:
127+
with gzip.GzipFile(filename=xmlfile, mode='w', mtime=0) as f:
128128
tree.write(f, 'utf-8') # type: ignore
129129

130130

tests/test_devhelp.py

+17
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
"""Test for devhelp extension."""
2+
from time import sleep
23

34
import pytest
45

56

67
@pytest.mark.sphinx('devhelp', testroot='basic')
78
def test_basic(app, status, warning):
89
app.builder.build_all()
10+
11+
12+
@pytest.mark.sphinx('devhelp', testroot='basic', freshenv=True)
13+
def test_basic_deterministic_build(app):
14+
app.config.devhelp_basename, output_filename = 'testing', 'testing.devhelp.gz'
15+
16+
app.builder.build_all()
17+
output_initial = (app.outdir / output_filename).read_bytes()
18+
19+
sleep(2)
20+
21+
app.builder.build_all()
22+
output_repeat = (app.outdir / output_filename).read_bytes()
23+
24+
msg = f"Content of '{output_filename}' differed between builds."
25+
assert output_repeat == output_initial, msg

0 commit comments

Comments
 (0)