coverage
This commit is contained in:
@ -29,6 +29,8 @@ def display_list(lst, separator='and'):
|
||||
ret = lst[0]
|
||||
if isinstance(ret, unicode):
|
||||
ret = ret.encode('utf8')
|
||||
if not isinstance(ret, str):
|
||||
ret = str(ret)
|
||||
return ret
|
||||
else:
|
||||
lst_ = []
|
||||
@ -41,6 +43,8 @@ def display_list(lst, separator='and'):
|
||||
last = lst[-1]
|
||||
if isinstance(last, unicode):
|
||||
last = last.encode('utf8')
|
||||
if not isinstance(last, str):
|
||||
last = str(last)
|
||||
return ', '.join(lst_) + _(' {} ').format(separator) + last
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
""
|
||||
# Copyright (C) 2014 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2014-2017 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -23,7 +23,7 @@ from ...setting import undefined
|
||||
from ...error import ConfigError
|
||||
static_tuple = tuple()
|
||||
static_set = frozenset()
|
||||
if sys.version_info[0] >= 3: # pragma: optional cover
|
||||
if sys.version_info[0] >= 3: # pragma: no cover
|
||||
xrange = range
|
||||
|
||||
|
||||
@ -286,7 +286,7 @@ class StorageBase(object):
|
||||
self._opt = opt
|
||||
|
||||
def _is_string(self, infos):
|
||||
if sys.version_info[0] >= 3: # pragma: optional cover
|
||||
if sys.version_info[0] >= 3: # pragma: no cover
|
||||
return isinstance(infos, str)
|
||||
else:
|
||||
return isinstance(infos, str) or isinstance(infos, unicode)
|
||||
@ -424,7 +424,7 @@ class StorageOptionDescription(StorageBase):
|
||||
raise AttributeError(_('no option {0} found').format(opt))
|
||||
return self._cache_paths[1][self._cache_paths[0].index(opt)]
|
||||
|
||||
def impl_get_group_type(self): # pragma: optional cover
|
||||
def impl_get_group_type(self):
|
||||
return self._group_type
|
||||
|
||||
def impl_build_cache_option(self, _currpath=None, cache_path=None,
|
||||
@ -467,7 +467,7 @@ class StorageOptionDescription(StorageBase):
|
||||
if dynopt == subopt:
|
||||
found = True
|
||||
break
|
||||
if not found:
|
||||
if not found: # pragma: no cover
|
||||
raise ConfigError(_('cannot find dynpath'))
|
||||
subpath = subpath + suffix
|
||||
for slength in xrange(length, len(spath)):
|
||||
@ -523,7 +523,7 @@ class StorageOptionDescription(StorageBase):
|
||||
return _filter_by_name(path, option)
|
||||
|
||||
opts, paths = self._cache_paths
|
||||
for index in range(0, len(paths)):
|
||||
for index in xrange(0, len(paths)):
|
||||
option = opts[index]
|
||||
if option.impl_is_optiondescription():
|
||||
continue
|
||||
@ -556,7 +556,7 @@ class StorageOptionDescription(StorageBase):
|
||||
def _getattr(self, name, suffix=undefined, context=undefined, dyn=True):
|
||||
error = False
|
||||
if suffix is not undefined:
|
||||
if undefined in [suffix, context]: # pragma: optional cover
|
||||
if undefined in [suffix, context]: # pragma: no cover
|
||||
raise ConfigError(_("suffix and context needed if "
|
||||
"it's a dyn option"))
|
||||
if name.endswith(suffix):
|
||||
|
@ -35,9 +35,6 @@ class Values(Cache):
|
||||
def getsession(self):
|
||||
pass
|
||||
|
||||
def delsession(self, session):
|
||||
pass
|
||||
|
||||
def _setvalue_info(self, nb, idx, value, values, index, vidx):
|
||||
lst = list(self._values[nb])
|
||||
if idx is None:
|
||||
@ -82,8 +79,6 @@ class Values(Cache):
|
||||
if isinstance(value, list):
|
||||
value = tuple(value)
|
||||
vidx = self._setvalue_info(2, idx, value, values, index, vidx)
|
||||
if isinstance(value, list):
|
||||
value = tuple(value)
|
||||
self._setvalue_info(3, idx, owner, values, index, vidx)
|
||||
self._values = tuple(values)
|
||||
|
||||
@ -183,32 +178,20 @@ class Values(Cache):
|
||||
_values == ((path1, path2), ((idx1_1, idx1_2), None), ((value1_1, value1_2), value2), ((owner1_1, owner1_2), owner2))
|
||||
"""
|
||||
if path in self._values[0]:
|
||||
idx = self._values[0].index(path)
|
||||
if isinstance(self._values[1][idx], tuple):
|
||||
if index is None:
|
||||
raise ValueError('index is mandatory')
|
||||
elif index is not None:
|
||||
raise ValueError('index is forbidden')
|
||||
|
||||
if self._values[1][idx] is None:
|
||||
if index is None:
|
||||
value = self._values[nb][idx]
|
||||
else:
|
||||
value = self._values[nb][idx][index]
|
||||
path_idx = self._values[0].index(path)
|
||||
indexes = self._values[1][path_idx]
|
||||
if indexes is None:
|
||||
if index is not None: # pragma: no cover
|
||||
raise ValueError('index is forbidden')
|
||||
value = self._values[nb][path_idx]
|
||||
else:
|
||||
if index is not None:
|
||||
if index in self._values[1][idx]:
|
||||
subidx = self._values[1][idx].index(index)
|
||||
value = self._values[nb][idx][subidx]
|
||||
else:
|
||||
value = undefined
|
||||
if index is None: # pragma: no cover
|
||||
raise ValueError('index is mandatory')
|
||||
if index in indexes:
|
||||
subidx = indexes.index(index)
|
||||
value = self._values[nb][path_idx][subidx]
|
||||
else:
|
||||
value = []
|
||||
for i in xrange(0, max(self._values[1][idx])):
|
||||
if i in self._values[1][idx]:
|
||||
value.append(self._values[nb][idx][self._values[1][idx].index(i)])
|
||||
else:
|
||||
value.append(undefined)
|
||||
value = undefined
|
||||
else:
|
||||
value = undefined
|
||||
if isinstance(value, tuple):
|
||||
|
@ -19,7 +19,7 @@ from ..setting import owners
|
||||
|
||||
|
||||
class SerializeObject(object):
|
||||
def __getstate__(self):
|
||||
def __getstate__(self): # pragma: no cover
|
||||
ret = {}
|
||||
for key in dir(self):
|
||||
if not key.startswith('__'):
|
||||
@ -53,7 +53,7 @@ class Cache(object):
|
||||
str_owner = []
|
||||
_value.append(value[2])
|
||||
for owner in value[3]:
|
||||
if isinstance(owner, list):
|
||||
if isinstance(owner, list): # pragma: no cover
|
||||
str_owners = []
|
||||
for subowner in owner:
|
||||
str_owners.append(str(subowner))
|
||||
@ -64,7 +64,7 @@ class Cache(object):
|
||||
states[slot] = _value
|
||||
else:
|
||||
states[slot] = value
|
||||
except AttributeError:
|
||||
except AttributeError: # pragma: no cover
|
||||
pass
|
||||
return states
|
||||
|
||||
@ -72,7 +72,7 @@ class Cache(object):
|
||||
def convert_owner(owner):
|
||||
try:
|
||||
owner = getattr(owners, owner)
|
||||
except AttributeError:
|
||||
except AttributeError: # pragma: no cover
|
||||
owners.addowner(owner)
|
||||
owner = getattr(owners, owner)
|
||||
return owner
|
||||
@ -86,7 +86,7 @@ class Cache(object):
|
||||
_value.append(value[2])
|
||||
obj_owner = []
|
||||
for owner in value[3]:
|
||||
if isinstance(owner, list):
|
||||
if isinstance(owner, list): # pragma: no cover
|
||||
obj_owners = []
|
||||
for subowner in owner:
|
||||
obj_owners.append(convert_owner(subowner))
|
||||
@ -104,7 +104,7 @@ class Cache(object):
|
||||
value, created = self._cache[path][index]
|
||||
if created is None or exp <= created:
|
||||
return True, value
|
||||
return False, None
|
||||
return False, None # pragma: no cover
|
||||
|
||||
def hascache(self, path, index):
|
||||
""" path is in the cache
|
||||
|
Reference in New Issue
Block a user