Beispiel #1
0
    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}
Beispiel #2
0
    def test_string(self):
        lhs = ['10', 20]
        rhs = '15'

        value = utils.cons(lhs, rhs)

        assert value == ['10', 20, '15']
Beispiel #3
0
    def test_scalar(self):
        lhs = [10, 20]
        rhs = 15

        value = utils.cons(lhs, rhs)

        assert value == [10, 20, 15]
Beispiel #4
0
    def test_list(self):
        lhs = [10, 20]
        rhs = [15]

        value = utils.cons(lhs, rhs)

        assert value == [10, 20, 15]
Beispiel #5
0
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
Beispiel #6
0
    def test_mapping(self):
        value = {'x': 10, 'y': 20}
        value = utils.cons(value, {'z': 15})

        assert value == {'x': 10, 'y': 20, 'z': 15}
Beispiel #7
0
    def test_string(self):
        value = ['10', 20]
        value = utils.cons(value, '15')

        assert value == ['10', 20, '15']
Beispiel #8
0
    def test_scalar(self):
        value = [10, 20]
        value = utils.cons(value, 15)

        assert value == [10, 20, 15]
Beispiel #9
0
    def test_list(self):
        value = [10, 20]
        value = utils.cons(value, [15])

        assert value == [10, 20, 15]