Fix doc tests

This commit is contained in:
Andrew Resch 2008-11-06 05:42:15 +00:00
parent f4e81e1429
commit 5b96fd1d49
1 changed files with 14 additions and 9 deletions

View File

@ -111,6 +111,11 @@ class Config(object):
5 5
""" """
if not self.__config.has_key(key):
self.__config[key] = value
log.debug("Setting '%s' to %s of %s", key, value, type(value))
return
if self.__config[key] == value: if self.__config[key] == value:
return return
@ -178,10 +183,9 @@ class Config(object):
>>> config = Config("test.conf", defaults={"test": 5}) >>> config = Config("test.conf", defaults={"test": 5})
>>> def cb(key, value): >>> def cb(key, value):
>>> print key, value ... print key, value
...
>>> config.register_change_callback(cb) >>> config.register_change_callback(cb)
>>> config["test"] = 4
test 4
""" """
self.__change_callback = callback self.__change_callback = callback
@ -198,10 +202,10 @@ class Config(object):
>>> config = Config("test.conf", defaults={"test": 5}) >>> config = Config("test.conf", defaults={"test": 5})
>>> def cb(key, value): >>> def cb(key, value):
>>> print key, value ... print key, value
>>> config.register_set_function("test", cb) ...
>>> config["test"] = 4 >>> config.register_set_function("test", cb, apply_now=True)
test 4 test 5
""" """
log.debug("Registering function for %s key..", key) log.debug("Registering function for %s key..", key)
@ -219,8 +223,9 @@ class Config(object):
>>> config = Config("test.conf", defaults={"test": 5}) >>> config = Config("test.conf", defaults={"test": 5})
>>> def cb(key, value): >>> def cb(key, value):
>>> print key, value ... print key, value
>>> config.register_set_function("test", cb) ...
>>> config.register_set_function("test", cb, apply_now=False)
>>> config.apply_all() >>> config.apply_all()
test 5 test 5