Testing: Check that an error is raised for invalid shortcut options

Esse commit está contido em:
Carlos Cordoba
2024-11-30 11:19:52 -05:00
commit 7b1a3fe33f
2 arquivos alterados com 30 adições e 1 exclusões
+6 -1
Ver Arquivo
@@ -109,7 +109,12 @@ def pytest_collection_modifyitems(config, items):
@pytest.fixture(autouse=True)
def reset_conf_before_test():
def reset_conf_before_test(request):
# To prevent running this fixture for a specific test, you need to use this
# marker.
if 'no_reset_conf' in request.keywords:
return
from spyder.config.manager import CONF
CONF.reset_to_defaults(notification=False)
+24
Ver Arquivo
@@ -377,6 +377,30 @@ def test_userconfig_cleanup(userconfig):
assert not os.path.isfile(configpath)
@pytest.mark.no_reset_conf
def test_invalid_shortcuts(tmp_path):
name = 'invalid-shortcuts'
path = str(tmp_path)
for defaults in [
# Shortcut is not of the form context/name
[('shortcuts', {'foo': "Ctrl+I"})],
# Shortcut contains more than one slash, which breaks the way we parse
# them
[('shortcuts', {'editor/foo/bar': "Ctrl+I"})],
]:
with pytest.raises(ValueError):
UserConfig(
name=name,
path=path,
defaults=defaults,
load=False,
version="1.0.0",
backup=False,
raw_mode=True,
)
# --- SpyderUserConfig tests
# ============================================================================
# --- Compatibility API