|
8 | 8 |
|
9 | 9 | import sphinx |
10 | 10 | from sphinx.builders.gettext import _gettext_compact_validator |
11 | | -from sphinx.config import ENUM, Config, _Opt, check_confval_types |
| 11 | +from sphinx.config import ( |
| 12 | + ENUM, |
| 13 | + Config, |
| 14 | + _Opt, |
| 15 | + check_confval_types, |
| 16 | + correct_copyright_year, |
| 17 | +) |
12 | 18 | from sphinx.deprecation import RemovedInSphinx90Warning |
13 | 19 | from sphinx.errors import ConfigError, ExtensionError, VersionRequirementError |
14 | 20 |
|
@@ -556,6 +562,24 @@ def test_multi_line_copyright(source_date_year, app, monkeypatch): |
556 | 562 | ) in content |
557 | 563 |
|
558 | 564 |
|
| 565 | +@pytest.mark.parametrize(('conf_copyright', 'expected_copyright'), [ |
| 566 | + ('1970', '{current_year}'), |
| 567 | + # https://github.com/sphinx-doc/sphinx/issues/11913 |
| 568 | + ('1970-1990', '1970-{current_year}'), |
| 569 | + ('1970-1990 Alice', '1970-{current_year} Alice'), |
| 570 | +]) |
| 571 | +def test_correct_copyright_year(conf_copyright, expected_copyright, source_date_year): |
| 572 | + config = Config({}, {'copyright': conf_copyright}) |
| 573 | + correct_copyright_year(_app=None, config=config) |
| 574 | + actual_copyright = config['copyright'] |
| 575 | + |
| 576 | + if source_date_year is None: |
| 577 | + expected_copyright = conf_copyright |
| 578 | + else: |
| 579 | + expected_copyright = expected_copyright.format(current_year=source_date_year) |
| 580 | + assert actual_copyright == expected_copyright |
| 581 | + |
| 582 | + |
559 | 583 | def test_gettext_compact_command_line_true(): |
560 | 584 | config = Config({}, {'gettext_compact': '1'}) |
561 | 585 | config.add('gettext_compact', True, '', {bool, str}) |
|
0 commit comments