mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge branch '7.1.x'
# Conflicts: # CHANGES # sphinx/__init__.py # sphinx/config.py
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"""Test the sphinx.config.Config class."""
|
||||
|
||||
import time
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
@@ -444,23 +445,67 @@ def test_conf_py_nitpick_ignore_list(tempdir):
|
||||
assert cfg.nitpick_ignore_regex == []
|
||||
|
||||
|
||||
@pytest.fixture(params=[
|
||||
# test with SOURCE_DATE_EPOCH unset: no modification
|
||||
None,
|
||||
# test with SOURCE_DATE_EPOCH set: copyright year should be updated
|
||||
1293840000,
|
||||
1293839999,
|
||||
])
|
||||
def source_date_year(request, monkeypatch):
|
||||
sde = request.param
|
||||
with monkeypatch.context() as m:
|
||||
if sde:
|
||||
m.setenv('SOURCE_DATE_EPOCH', sde)
|
||||
yield time.gmtime(sde).tm_year
|
||||
else:
|
||||
m.delenv('SOURCE_DATE_EPOCH', raising=False)
|
||||
yield None
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='copyright-multiline')
|
||||
def test_multi_line_copyright(app, status, warning):
|
||||
def test_multi_line_copyright(source_date_year, app, monkeypatch):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf-8')
|
||||
|
||||
assert ' © Copyright 2006-2009, Alice.<br/>' in content
|
||||
assert ' © Copyright 2010-2013, Bob.<br/>' in content
|
||||
assert ' © Copyright 2014-2017, Charlie.<br/>' in content
|
||||
assert ' © Copyright 2018-2021, David.<br/>' in content
|
||||
assert ' © Copyright 2022-2025, Eve.' in content
|
||||
if source_date_year is None:
|
||||
# check the copyright footer line by line (empty lines ignored)
|
||||
assert ' © Copyright 2006-2009, Alice.<br/>\n' in content
|
||||
assert ' © Copyright 2010-2013, Bob.<br/>\n' in content
|
||||
assert ' © Copyright 2014-2017, Charlie.<br/>\n' in content
|
||||
assert ' © Copyright 2018-2021, David.<br/>\n' in content
|
||||
assert ' © Copyright 2022-2025, Eve.' in content
|
||||
|
||||
lines = (
|
||||
' © Copyright 2006-2009, Alice.<br/>\n \n'
|
||||
' © Copyright 2010-2013, Bob.<br/>\n \n'
|
||||
' © Copyright 2014-2017, Charlie.<br/>\n \n'
|
||||
' © Copyright 2018-2021, David.<br/>\n \n'
|
||||
' © Copyright 2022-2025, Eve.\n \n'
|
||||
)
|
||||
assert lines in content
|
||||
# check the raw copyright footer block (empty lines included)
|
||||
assert (
|
||||
' © Copyright 2006-2009, Alice.<br/>\n'
|
||||
' \n'
|
||||
' © Copyright 2010-2013, Bob.<br/>\n'
|
||||
' \n'
|
||||
' © Copyright 2014-2017, Charlie.<br/>\n'
|
||||
' \n'
|
||||
' © Copyright 2018-2021, David.<br/>\n'
|
||||
' \n'
|
||||
' © Copyright 2022-2025, Eve.'
|
||||
) in content
|
||||
else:
|
||||
# check the copyright footer line by line (empty lines ignored)
|
||||
assert f' © Copyright 2006-{source_date_year}, Alice.<br/>\n' in content
|
||||
assert f' © Copyright 2010-{source_date_year}, Bob.<br/>\n' in content
|
||||
assert f' © Copyright 2014-{source_date_year}, Charlie.<br/>\n' in content
|
||||
assert f' © Copyright 2018-{source_date_year}, David.<br/>\n' in content
|
||||
assert f' © Copyright 2022-{source_date_year}, Eve.' in content
|
||||
|
||||
# check the raw copyright footer block (empty lines included)
|
||||
assert (
|
||||
f' © Copyright 2006-{source_date_year}, Alice.<br/>\n'
|
||||
f' \n'
|
||||
f' © Copyright 2010-{source_date_year}, Bob.<br/>\n'
|
||||
f' \n'
|
||||
f' © Copyright 2014-{source_date_year}, Charlie.<br/>\n'
|
||||
f' \n'
|
||||
f' © Copyright 2018-{source_date_year}, David.<br/>\n'
|
||||
f' \n'
|
||||
f' © Copyright 2022-{source_date_year}, Eve.'
|
||||
) in content
|
||||
|
||||
Reference in New Issue
Block a user