Config: __str__ raise if no str/unicode value
This commit is contained in:
parent
0afb521766
commit
c06659012b
|
@ -1,10 +1,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#this test is much more to test that **it's there** and answers attribute access
|
||||
import autopath
|
||||
from py.test import raises
|
||||
|
||||
from tiramisu.config import Config
|
||||
from tiramisu.option import IntOption, FloatOption, StrOption, ChoiceOption, \
|
||||
BoolOption, OptionDescription
|
||||
BoolOption, UnicodeOption, OptionDescription
|
||||
|
||||
|
||||
def make_description():
|
||||
|
@ -112,3 +113,15 @@ def test_information_config():
|
|||
string = 'some informations'
|
||||
config.impl_set_information('info', string)
|
||||
assert config.impl_get_information('info') == string
|
||||
|
||||
|
||||
def test_information_display():
|
||||
g1 = IntOption('g1', '', 1)
|
||||
g2 = StrOption('g2', '', 'héhé')
|
||||
g3 = UnicodeOption('g3', '', u'héhé')
|
||||
g4 = BoolOption('g4', '', True)
|
||||
g5 = StrOption('g5', '')
|
||||
d1 = OptionDescription('od', '', [g1, g2, g3, g4, g5])
|
||||
root = OptionDescription('root', '', [d1])
|
||||
config = Config(root)
|
||||
str(config.od)
|
||||
|
|
|
@ -135,9 +135,11 @@ class SubConfig(BaseInformation):
|
|||
for name, grp in self.iter_groups():
|
||||
lines.append("[{0}]".format(name))
|
||||
for name, value in self:
|
||||
value = value.encode(default_encoding)
|
||||
try:
|
||||
lines.append("{0} = {1}".format(name, value))
|
||||
except UnicodeEncodeError:
|
||||
lines.append("{0} = {1}".format(name,
|
||||
value.encode(default_encoding)))
|
||||
except PropertiesOptionError:
|
||||
pass
|
||||
return '\n'.join(lines)
|
||||
|
|
Loading…
Reference in New Issue