Support for mutable and immutable configurations
This commit is contained in:
+24
-1
@@ -14,6 +14,7 @@
|
||||
|
||||
from src.config_parser.ini import INIConfiguration, INIConfigurationSection
|
||||
from src.config_parser.exceptions import INISyntaxError
|
||||
from src.config_parser import set_mutability
|
||||
|
||||
def test_generating():
|
||||
config = INIConfiguration()
|
||||
@@ -71,4 +72,26 @@ l2=w2''')
|
||||
assert dict(INIConfiguration.from_string('''[section1]
|
||||
k1=v1
|
||||
k2=v2
|
||||
k4=v4''', default = default_configuration)) == {'section1': {'k1': 'v1', 'k2': 'v2', 'k3': 'v3', 'k4': 'v4'}, 'section2': {'l1': 'w1', 'l2': 'w2'}}
|
||||
k4=v4''', default = default_configuration)) == {'section1': {'k1': 'v1', 'k2': 'v2', 'k3': 'v3', 'k4': 'v4'}, 'section2': {'l1': 'w1', 'l2': 'w2'}}
|
||||
|
||||
def test_mutability():
|
||||
config = INIConfiguration(mutable=False)
|
||||
try:
|
||||
config.key = 'value'
|
||||
assert False, 'Expected TypeError'
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
set_mutability(config, True)
|
||||
assert config._mutable == True
|
||||
|
||||
config.key = 'value'
|
||||
|
||||
set_mutability(config, False)
|
||||
assert config._mutable == False
|
||||
|
||||
try:
|
||||
del config.key
|
||||
assert False, 'Expected TypeError'
|
||||
except TypeError:
|
||||
pass
|
||||
Reference in New Issue
Block a user