in __setattr__, name should never be object's variable name
remove context in type_ find's option find_first_context return AttributError if no results
This commit is contained in:
@ -136,6 +136,17 @@ def test_reset_cache():
|
||||
assert 'u2' not in settings._p_.get_cached('property', c)
|
||||
|
||||
|
||||
def test_reset_cache_subconfig():
|
||||
od1 = make_description()
|
||||
od2 = OptionDescription('od2', '', [od1])
|
||||
c = Config(od2)
|
||||
values = c.cfgimpl_get_values()
|
||||
c.od1.u1
|
||||
assert 'od1.u1' in values._p_.get_cached('value', c)
|
||||
c.od1.cfgimpl_reset_cache()
|
||||
assert 'od1.u1' not in values._p_.get_cached('value', c)
|
||||
|
||||
|
||||
def test_reset_cache_only_expired():
|
||||
od1 = make_description()
|
||||
c = Config(od1)
|
||||
|
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""theses tests are much more to test that config, option description, vs...
|
||||
"""theses tests are much more to test that config, option description, vs...
|
||||
**it's there** and answers via attribute access"""
|
||||
|
||||
import autopath
|
||||
@ -45,6 +45,10 @@ def test_base_config():
|
||||
assert dm._name == 'dummy'
|
||||
|
||||
|
||||
def test_not_config():
|
||||
assert raises(TypeError, "Config('str')")
|
||||
|
||||
|
||||
def test_base_path():
|
||||
gcdummy = BoolOption('dummy', 'dummy', default=False)
|
||||
descr = OptionDescription('tiramisu', '', [gcdummy])
|
||||
@ -147,4 +151,9 @@ def test_information_display():
|
||||
d1 = OptionDescription('od', '', [g1, g2, g3, g4, g5])
|
||||
root = OptionDescription('root', '', [d1])
|
||||
config = Config(root)
|
||||
str(config.od)
|
||||
config.od == """g1 = 1
|
||||
g2 = héhé
|
||||
g3 = héhé
|
||||
g4 = True
|
||||
g5 = None"""
|
||||
config == '[od]'
|
||||
|
@ -48,7 +48,8 @@ def test_compare_configs():
|
||||
conf1.gc.dummy = True
|
||||
assert conf1 == conf2
|
||||
assert hash(conf1) == hash(conf2)
|
||||
#assert conf1.getkey() == conf2.getkey()
|
||||
assert not conf1 == 'conf2'
|
||||
assert conf1 != 'conf2'
|
||||
# ____________________________________________________________
|
||||
|
||||
|
||||
|
@ -150,6 +150,7 @@ def test_meta_meta_set():
|
||||
conf1.od1.i1 = 8
|
||||
assert [conf2] == meta2.find_first_contexts(byname='i1', byvalue=7)
|
||||
assert [conf1] == meta2.find_first_contexts(byname='i1', byvalue=8)
|
||||
raises(AttributeError, "meta2.find_first_contexts(byname='i1', byvalue=10)")
|
||||
|
||||
|
||||
def test_not_meta():
|
||||
|
@ -104,6 +104,13 @@ def test_iter_on_empty_group():
|
||||
assert [] == list(config)
|
||||
|
||||
|
||||
def test_iter_not_group():
|
||||
config = Config(OptionDescription("name", "descr", []))
|
||||
config.read_write()
|
||||
raises(TypeError, "list(config.iter_groups(group_type='family'))")
|
||||
|
||||
|
||||
|
||||
def test_groups_with_master():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
|
Reference in New Issue
Block a user