sphinx/tests/test_correct_year.py
Jon Dufresne bade33c7e4 Remove unnecessary encoding cookie from Python source files
In Python 3, the default encoding of source files is utf-8. The encoding
cookie is now unnecessary and redundant so remove it. For more details,
see the docs:

https://docs.python.org/3/howto/unicode.html#the-string-type

> The default encoding for Python source code is UTF-8, so you can
> simply include a Unicode character in a string literal ...

Includes a fix for the flake8 header checks to stop expecting an
encoding cookie.
2018-12-16 12:22:12 -08:00

37 lines
919 B
Python

"""
test_correct_year
~~~~~~~~~~~~~~~~~
Test copyright year adjustment
:copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
import pytest
@pytest.fixture(
params=[
# test with SOURCE_DATE_EPOCH unset: no modification
(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()
content = (app.outdir / 'index.html').text()
assert expect_date in content