mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Introduce a configuration option type
* Normalise rebuild values * Ensure that the tuple interface continues to work
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
"""Test the sphinx.config.Config class."""
|
||||
|
||||
import pickle
|
||||
import time
|
||||
from pathlib import Path
|
||||
from unittest import mock
|
||||
@@ -7,10 +7,24 @@ from unittest import mock
|
||||
import pytest
|
||||
|
||||
import sphinx
|
||||
from sphinx.config import ENUM, Config, check_confval_types
|
||||
from sphinx.config import ENUM, Config, _Opt, check_confval_types
|
||||
from sphinx.deprecation import RemovedInSphinx90Warning
|
||||
from sphinx.errors import ConfigError, ExtensionError, VersionRequirementError
|
||||
|
||||
|
||||
def test_config_opt_deprecated(recwarn):
|
||||
opt = _Opt('default', '', ())
|
||||
|
||||
with pytest.warns(RemovedInSphinx90Warning):
|
||||
default, rebuild, valid_types = opt
|
||||
|
||||
with pytest.warns(RemovedInSphinx90Warning):
|
||||
_ = opt[0]
|
||||
|
||||
with pytest.warns(RemovedInSphinx90Warning):
|
||||
_ = list(opt)
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='config', confoverrides={
|
||||
'root_doc': 'root',
|
||||
'nonexisting_value': 'True',
|
||||
@@ -71,6 +85,16 @@ def test_config_not_found(tmp_path):
|
||||
Config.read(tmp_path)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("protocol", list(range(pickle.HIGHEST_PROTOCOL)))
|
||||
def test_config_pickle_protocol(tmp_path, protocol: int):
|
||||
config = Config()
|
||||
|
||||
pickled_config = pickle.loads(pickle.dumps(config, protocol))
|
||||
|
||||
assert list(config.values) == list(pickled_config.values)
|
||||
assert repr(config) == repr(pickled_config)
|
||||
|
||||
|
||||
def test_extension_values():
|
||||
config = Config()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user