Remove config.val support for config.py

This commit is contained in:
Florian Bruhin 2017-09-15 13:35:30 +02:00
parent 25baf3b97e
commit f406e8d9ca
2 changed files with 9 additions and 2 deletions

View File

@ -157,7 +157,6 @@ def read_config_py(filename=None):
api = ConfigAPI(config.instance, config.key_instance)
container = config.ConfigContainer(config.instance, configapi=api)
api.val = container
module = types.ModuleType('config')
module.config = api

View File

@ -115,7 +115,6 @@ class TestConfigPy:
@pytest.mark.parametrize('line', [
'c.colors.hints.bg = "red"',
'config.val.colors.hints.bg = "red"',
'config.set("colors.hints.bg", "red")',
])
def test_set(self, confpy, line):
@ -233,6 +232,15 @@ class TestConfigPy:
assert tblines[-1] == "ZeroDivisionError: division by zero"
assert " 1/0" in tblines
def test_config_val(self, confpy):
"""Using config.val should not work in config.py files."""
confpy.write("config.val.colors.hints.bg = 'red'")
api = configfiles.read_config_py(confpy.filename)
assert len(api.errors) == 1
error = api.errors[0]
assert error.text == "Unhandled exception"
assert isinstance(error.exception, AttributeError)
@pytest.mark.parametrize('line', ["c.foo = 42", "config.set('foo', 42)"])
def test_config_error(self, confpy, line):
confpy.write(line, "config.load_autoconfig = False")