def test_mapping(self): lhs = {'x': 10, 'y': 20} rhs = {'z': 15} value = utils.cons(lhs, rhs) assert value == {'x': 10, 'y': 20, 'z': 15}
def test_string(self): lhs = ['10', 20] rhs = '15' value = utils.cons(lhs, rhs) assert value == ['10', 20, '15']
def test_scalar(self): lhs = [10, 20] rhs = 15 value = utils.cons(lhs, rhs) assert value == [10, 20, 15]
def test_list(self): lhs = [10, 20] rhs = [15] value = utils.cons(lhs, rhs) assert value == [10, 20, 15]
def _merge(options, name, bases, default=None): """Merges a named option collection.""" result = None for base in bases: if base is None: continue value = getattr(base, name, None) if value is None: continue result = utils.cons(result, value) value = options.get(name) if value is not None: result = utils.cons(result, value) return result or default
def test_mapping(self): value = {'x': 10, 'y': 20} value = utils.cons(value, {'z': 15}) assert value == {'x': 10, 'y': 20, 'z': 15}
def test_string(self): value = ['10', 20] value = utils.cons(value, '15') assert value == ['10', 20, '15']
def test_scalar(self): value = [10, 20] value = utils.cons(value, 15) assert value == [10, 20, 15]
def test_list(self): value = [10, 20] value = utils.cons(value, [15]) assert value == [10, 20, 15]