Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_collection_subclasses(self):
class DictA(MutableMapping):
def __init__(self, *args, **kwargs):
self.__dict__.update(*args, **kwargs)
def __setitem__(self, key, value):
self.__dict__[key] = value
def __getitem__(self, key):
return self.__dict__[key]
def __delitem__(self, key):
del self.__dict__[key]
def __iter__(self):
return iter(self.__dict__)
def __setitem__(self, key, value):
self.__dict__[key] = value
def __getitem__(self, key):
return self.__dict__[key]
def __delitem__(self, key):
del self.__dict__[key]
def __iter__(self):
return iter(self.__dict__)
def __len__(self):
return len(self.__dict__)
class DictB(MutableMapping):
def __init__(self, *args, **kwargs):
self.__dict__.update(*args, **kwargs)
def __setitem__(self, key, value):
self.__dict__[key] = value
def __getitem__(self, key):
return self.__dict__[key]
def __delitem__(self, key):
del self.__dict__[key]
def __iter__(self):
return iter(self.__dict__)
"""Dictdiffer is a helper module to diff and patch dictionaries."""
from copy import deepcopy
from ._compat import (PY2, Iterable, MutableMapping, MutableSequence,
MutableSet, string_types, text_type)
from .utils import EPSILON, PathLimit, are_different, dot_lookup
from .version import __version__
(ADD, REMOVE, CHANGE) = (
'add', 'remove', 'change')
__all__ = ('diff', 'patch', 'swap', 'revert', 'dot_lookup', '__version__')
DICT_TYPES = (MutableMapping, )
LIST_TYPES = (MutableSequence, )
SET_TYPES = (MutableSet, )
try:
import numpy
HAS_NUMPY = True
LIST_TYPES += (numpy.ndarray, )
except ImportError: # pragma: no cover
HAS_NUMPY = False
def diff(first, second, node=None, ignore=None, path_limit=None, expand=False,
tolerance=EPSILON, dot_notation=True):
"""Compare two dictionary/list/set objects, and returns a diff result.
Return an iterator with differences between two objects. The diff items