Testing: Check that an error is raised for invalid shortcut options
Esse commit está contido em:
+6
-1
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário