Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test_extension.py « tests - github.com/sphinx-doc/sphinx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ca35e0ae5e564ef8422b5f0b80f40cc217b7bcab (plain)
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
"""Test sphinx.extension module.

    :copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
"""

import pytest

from sphinx.errors import VersionRequirementError
from sphinx.extension import Extension, verify_needs_extensions


def test_needs_extensions(app):
    # empty needs_extensions
    assert app.config.needs_extensions == {}
    verify_needs_extensions(app, app.config)

    # needs_extensions fulfilled
    app.config.needs_extensions = {'test.extension': '3.9'}
    app.extensions['test.extension'] = Extension('test.extension', 'test.extension', version='3.10')
    verify_needs_extensions(app, app.config)

    # needs_extensions not fulfilled
    app.config.needs_extensions = {'test.extension': '3.11'}
    app.extensions['test.extension'] = Extension('test.extension', 'test.extension', version='3.10')
    with pytest.raises(VersionRequirementError):
        verify_needs_extensions(app, app.config)