Skip to content

Avoid storing build time in gzip headers #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading