Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Corrects copyright year using SOURCE_DATE_EPOCH if set
- Loading branch information
Alexis Bienvenüe
committed
Apr 28, 2016
1 parent
390ee6f
commit 7a89015
Showing
5 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
copyright = u'2006-2009, Author' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
================= | ||
test-correct-year | ||
================= | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
test_correct_year | ||
~~~~~~~~~~~~~~~~~ | ||
Test copyright year adjustment | ||
:copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS. | ||
:license: BSD, see LICENSE for details. | ||
""" | ||
import os | ||
|
||
from util import TestApp | ||
|
||
|
||
def test_correct_year(): | ||
# save current value of SOURCE_DATE_EPOCH | ||
sde = os.environ.pop('SOURCE_DATE_EPOCH',None) | ||
|
||
# test with SOURCE_DATE_EPOCH unset: no modification | ||
app = TestApp(buildername='html',testroot='correct-year') | ||
app.builder.build_all() | ||
content = (app.outdir / 'contents.html').text() | ||
app.cleanup() | ||
assert '2006-2009' in content | ||
|
||
# test with SOURCE_DATE_EPOCH set: copyright year should be | ||
# updated | ||
os.environ['SOURCE_DATE_EPOCH'] = "1293840000" | ||
app = TestApp(buildername='html',testroot='correct-year') | ||
app.builder.build_all() | ||
content = (app.outdir / 'contents.html').text() | ||
app.cleanup() | ||
assert '2006-2011' in content | ||
|
||
os.environ['SOURCE_DATE_EPOCH'] = "1293839999" | ||
app = TestApp(buildername='html',testroot='correct-year') | ||
app.builder.build_all() | ||
content = (app.outdir / 'contents.html').text() | ||
app.cleanup() | ||
assert '2006-2010' in content | ||
|
||
# Restores SOURCE_DATE_EPOCH | ||
if sde == None: | ||
os.environ.pop('SOURCE_DATE_EPOCH',None) | ||
else: | ||
os.environ['SOURCE_DATE_EPOCH'] = sde |