File: test_correct_year.py

package info (click to toggle)
sphinx 4.5.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 22,656 kB
  • sloc: python: 74,641; javascript: 14,242; perl: 420; makefile: 247; sh: 57; xml: 19; ansic: 1
file content (28 lines) | stat: -rw-r--r-- 759 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""Test copyright year adjustment"""
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').read_text()
    assert expect_date in content