Values validate now value

This commit is contained in:
2013-04-11 11:30:58 +02:00
parent 0c5ab9df18
commit 26568dc45a
7 changed files with 52 additions and 208 deletions

View File

@ -253,5 +253,5 @@ def test_freeze_and_has_callback_with_setoption():
config.cfgimpl_get_settings().enable_property('freeze')
dummy = config.unwrap_from_path('gc.dummy')
config.cfgimpl_get_settings().add_property('frozen', dummy)
raises(TypeError, "config.gc.setoption('dummy', True, 'gen_config')")
raises(TypeError, "config.gc.setoption('dummy', descr.gc.dummy, True)")
#____________________________________________________________

View File

@ -250,13 +250,13 @@ def test_choice_access_with_multi():
assert config.t1 == ["a", "b", "a", "b"]
# ____________________________________________________________
def test_setoption_from_option():
"a setoption directly from the option is **not** a good practice"
booloption = BoolOption('bool', 'Test boolean option', default=True)
descr = OptionDescription('descr', '', [booloption])
cfg = Config(descr)
booloption.setoption(cfg, False)
assert cfg.bool == False
#def test_setoption_from_option():
# "a setoption directly from the option is **not** a good practice"
# booloption = BoolOption('bool', 'Test boolean option', default=True)
# descr = OptionDescription('descr', '', [booloption])
# cfg = Config(descr)
# booloption.setoption(cfg, False)
# assert cfg.bool == False
#____________________________________________________________
def test_dwim_set():
descr = OptionDescription("opt", "", [
@ -347,18 +347,18 @@ def test_set_symlink_option():
## assert config.gc.dummy == True
#____________________________________________________________
def test_accepts_multiple_changes_from_option():
s = StrOption("string", "", default="string")
descr = OptionDescription("options", "", [s])
config = Config(descr)
config.string = "egg"
assert s.getdefault() == "string"
assert config.string == "egg"
s.setoption(config, 'blah')
assert s.getdefault() == "string"
assert config.string == "blah"
s.setoption(config, 'bol')
assert config.string == 'bol'
#def test_accepts_multiple_changes_from_option():
# s = StrOption("string", "", default="string")
# descr = OptionDescription("options", "", [s])
# config = Config(descr)
# config.string = "egg"
# assert s.getdefault() == "string"
# assert config.string == "egg"
# s.setoption(config, 'blah')
# assert s.getdefault() == "string"
# assert config.string == "blah"
# s.setoption(config, 'bol')
# assert config.string == 'bol'
def test_allow_multiple_changes_from_config():
"""
@ -370,8 +370,8 @@ def test_allow_multiple_changes_from_config():
suboption = OptionDescription("bip", "", [s2])
descr = OptionDescription("options", "", [s, suboption])
config = Config(descr)
config.setoption("string", 'blah', owners.user)
config.setoption("string", "oh", owners.user)
config.setoption("string", s, 'blah')
config.setoption("string", s, "oh")
assert config.string == "oh"
config.set(string2= 'blah')
assert config.bip.string2 == 'blah'

View File

@ -1,26 +0,0 @@
#this test is much more to test that **it's there** and answers attribute access
import autopath
from py.test import raises
from tool import extend
class A:
a = 'titi'
def tarte(self):
return "tart"
class B:
__metaclass__ = extend
def to_rst(self):
return "hello"
B.extend(A)
a = B()
def test_extendable():
assert a.a == 'titi'
assert a.tarte() == 'tart'
assert a.to_rst() == "hello"