Skip to content

Commit

Permalink
Avoid storing build time in gzip headers (#13)
Browse files Browse the repository at this point in the history
Co-authored-by: James Addison <jay@jp-hosting.net>
(cherry picked from commit 7278043)
  • Loading branch information
bmwiedemann authored and AA-Turner committed Jul 27, 2024
1 parent 1ace65f commit 13151e9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sphinxcontrib/devhelp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def write_index(title: str, refs: list[Any], subitems: Any) -> None:

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


Expand Down
17 changes: 17 additions & 0 deletions tests/test_devhelp.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
"""Test for devhelp extension."""
from time import sleep

import pytest


@pytest.mark.sphinx('devhelp', testroot='basic')
def test_basic(app, status, warning):
app.builder.build_all()


@pytest.mark.sphinx('devhelp', testroot='basic', freshenv=True)
def test_basic_deterministic_build(app):
app.config.devhelp_basename, output_filename = 'testing', 'testing.devhelp.gz'

app.builder.build_all()
output_initial = (app.outdir / output_filename).read_bytes()

sleep(2)

app.builder.build_all()
output_repeat = (app.outdir / output_filename).read_bytes()

msg = f"Content of '{output_filename}' differed between builds."
assert output_repeat == output_initial, msg

0 comments on commit 13151e9

Please sign in to comment.