def test_dict_merge(): assert dict_merge({}, {1: x, y: z}) == {1: x, y: z} assert dict_merge({1: x, y: z}, {}) == {1: x, y: z} assert dict_merge({2: z}, {1: x, y: z}) == {1: x, 2: z, y: z} assert dict_merge({1: x, y: z}, {2: z}) == {1: x, 2: z, y: z} assert dict_merge({1: y, 2: z}, {1: x, y: z}) == {1: x, 2: z, y: z} assert dict_merge({1: x, y: z}, {1: y, 2: z}) == {1: y, 2: z, y: z}
def wrapper(self, *args, **kwargs): return func(*args, **dict_merge(self.__options__, kwargs))
def __and__(self, other): if isinstance(other, Context): return Context(**dict_merge(self.__options__, other.__options__)) else: raise TypeError("a context manager expected, got %s" % other)
def __init__(self, dict=None, **options): if dict is not None: self.__options__ = dict_merge(dict, options) else: self.__options__ = options