2016-04-28 16:37:36 -05:00
|
|
|
"""
|
|
|
|
test_correct_year
|
|
|
|
~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Test copyright year adjustment
|
|
|
|
|
2019-01-02 01:00:30 -06:00
|
|
|
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
2016-04-28 16:37:36 -05:00
|
|
|
:license: BSD, see LICENSE for details.
|
|
|
|
"""
|
2017-01-06 09:46:26 -06:00
|
|
|
import pytest
|
2016-04-28 16:37:36 -05:00
|
|
|
|
2016-05-02 02:57:06 -05:00
|
|
|
|
2017-01-06 09:46:26 -06:00
|
|
|
@pytest.fixture(
|
|
|
|
params=[
|
2016-05-02 02:57:06 -05:00
|
|
|
# test with SOURCE_DATE_EPOCH unset: no modification
|
2017-01-06 09:46:26 -06:00
|
|
|
(None, '2006-2009'),
|
|
|
|
# test with SOURCE_DATE_EPOCH set: copyright year should be updated
|
|
|
|
('1293840000', '2006-2011'),
|
|
|
|
('1293839999', '2006-2010'),
|
|
|
|
],
|
|
|
|
|
|
|
|
)
|
|
|
|
def expect_date(request, monkeypatch):
|
|
|
|
sde, expect = request.param
|
|
|
|
if sde:
|
|
|
|
monkeypatch.setenv('SOURCE_DATE_EPOCH', sde)
|
|
|
|
else:
|
|
|
|
monkeypatch.delenv('SOURCE_DATE_EPOCH', raising=False)
|
|
|
|
yield expect
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx('html', testroot='correct-year')
|
|
|
|
def test_correct_year(expect_date, app):
|
|
|
|
app.build()
|
2018-09-03 07:38:31 -05:00
|
|
|
content = (app.outdir / 'index.html').text()
|
2017-01-06 09:46:26 -06:00
|
|
|
assert expect_date in content
|