python 3.4 support

This commit is contained in:
2016-03-19 21:27:37 +01:00
parent 924692d3ab
commit 7305cfa134
12 changed files with 62 additions and 23 deletions

View File

@ -372,7 +372,7 @@ def test_config_od_function():
descr = OptionDescription('tiramisu', '', [o])
cfg = Config(descr)
try:
print cfg.impl_get_opt_by_path()
except AttributeError, err:
print(cfg.impl_get_opt_by_path())
except AttributeError as err:
assert str(err) == _('unknown Option {0} in OptionDescription {1}'
'').format('impl_get_opt_by_path', descr.impl_getname())

View File

@ -1,7 +1,7 @@
from autopath import do_autopath
do_autopath()
import warnings
import warnings, sys
from py.test import raises
from tiramisu.config import Config
@ -49,15 +49,21 @@ def test_domainname_upper():
has_error = False
try:
c.d = 'TOTO.COM'
except ValueError, err:
assert msg in unicode(err)
except ValueError as err:
if sys.version_info[0] >= 3: # pragma: optional cover
assert msg in str(err)
else:
assert msg in unicode(err)
has_error = True
assert has_error is True
has_error = False
try:
c.d = 'toTo.com'
except ValueError, err:
assert msg in unicode(err)
except ValueError as err:
if sys.version_info[0] >= 3: # pragma: optional cover
assert msg in str(err)
else:
assert msg in unicode(err)
has_error = True
assert has_error is True

View File

@ -207,7 +207,7 @@ def test_prop_dyndescription():
assert str(cfg.cfgimpl_get_settings()[stval2]) in [str(['test']), str([u'test'])]
cfg.cfgimpl_get_settings()[stval2].append('test2')
assert str(cfg.cfgimpl_get_settings()[stval1]) in [str(['test']), str([u'test'])]
assert str(cfg.cfgimpl_get_settings()[stval2]) in [str(['test', 'test2']), str([u'test', 'test2'])]
assert str(cfg.cfgimpl_get_settings()[stval2]) in [str(['test', 'test2']), str([u'test', 'test2']), str(['test2', 'test'])]
cfg.cfgimpl_get_settings()[stval1].remove('test')
assert str(cfg.cfgimpl_get_settings()[stval1]) == str([])
#
@ -417,7 +417,7 @@ def test_prop_dyndescription_context():
assert str(cfg.cfgimpl_get_settings()[stval2]) in [str(['test']), str([u'test'])]
cfg.cfgimpl_get_settings()[stval2].append('test2')
assert str(cfg.cfgimpl_get_settings()[stval1]) in [str(['test']), str([u'test'])]
assert str(cfg.cfgimpl_get_settings()[stval2]) in [str(['test', 'test2']), str([u'test', 'test2'])]
assert str(cfg.cfgimpl_get_settings()[stval2]) in [str(['test', 'test2']), str([u'test', 'test2']), str(['test2', 'test'])]
cfg.cfgimpl_get_settings()[stval1].remove('test')
assert str(cfg.cfgimpl_get_settings()[stval1]) == str([])
@ -1346,7 +1346,7 @@ def test_invalid_samevalue_dyndescription():
od = OptionDescription('od', '', [dod])
cfg = Config(od)
cfg
raises(ConfigError, "print cfg")
raises(ConfigError, "print(cfg)")
def test_invalid_name_dyndescription():
@ -1355,4 +1355,4 @@ def test_invalid_name_dyndescription():
od = OptionDescription('od', '', [dod])
cfg = Config(od)
cfg
raises(ValueError, "print cfg")
raises(ValueError, "print(cfg)")

View File

@ -10,6 +10,7 @@ from tiramisu.storage import delete_session
from tiramisu.error import ConfigError
from pickle import dumps, loads
from py.test import raises
import sys
def return_value(value=None):
@ -460,7 +461,7 @@ def test_state_groupconfig():
def test_state_unkown_setting_owner():
"""load an unknow _owner, should create it"""
assert not 'supernewuser' in owners.__dict__
loads("""ccopy_reg
val = """ccopy_reg
_reconstructor
p0
(ctiramisu.setting
@ -496,5 +497,8 @@ sS'_properties'
p17
(dp18
sbsb.
.""")
."""
if sys.version_info[0] >= 3: # pragma: optional cover
val = bytes(val, "UTF-8")
loads(val)
assert 'supernewuser' in owners.__dict__