# Path: mockito/mocking.py
# class Mock(object):
#     def __init__(self, mocked_obj, strict=True, spec=None):
#         self.mocked_obj = mocked_obj
#         self.strict = strict
#         self.spec = spec
# 
#         self.invocations = deque()  # type: Deque[RealInvocation]
#         self.stubbed_invocations = deque()  # type: Deque[invocation.StubbedInvocation]
# 
#         self.original_methods = {}
#         self._signatures_store = {}
# 
#     def remember(self, invocation):
#         self.invocations.appendleft(invocation)
# 
#     def finish_stubbing(self, stubbed_invocation):
#         self.stubbed_invocations.appendleft(stubbed_invocation)
# 
#     def clear_invocations(self):
#         self.invocations = deque()
# 
#     # STUBBING
# 
#     def get_original_method(self, method_name):
#         """
#         Looks up the original method on the `spec` object and returns it
#         together with an indication of whether the method is found
#         "directly" on the `spec` object.
# 
#         This is used to decide whether the method should be stored as an
#         original_method and should therefore be replaced when unstubbing.
#         """
#         if self.spec is None:
#             return None, False
# 
#         try:
#             return self.spec.__dict__[method_name], True
#         except (AttributeError, KeyError):
#             # Classes with defined `__slots__` and then no `__dict__` are not
#             # patchable but if we catch the `AttributeError` here, we get
#             # the better error message for the user.
#             return getattr(self.spec, method_name, None), False
# 
#     def set_method(self, method_name, new_method):
#         setattr(self.mocked_obj, method_name, new_method)
# 
#     def replace_method(self, method_name, original_method):
# 
#         def new_mocked_method(*args, **kwargs):
#             # we throw away the first argument, if it's either self or cls
#             if (
#                 inspect.ismethod(new_mocked_method)
#                 or inspect.isclass(self.mocked_obj)
#                 and not isinstance(new_mocked_method, staticmethod)
#             ):
#                 args = args[1:]
# 
#             return remembered_invocation_builder(
#                 self, method_name, *args, **kwargs)
# 
#         new_mocked_method.__name__ = method_name
#         if original_method:
#             new_mocked_method.__doc__ = original_method.__doc__
#             new_mocked_method.__wrapped__ = original_method  # type: ignore[attr-defined]
#             try:
#                 new_mocked_method.__module__ = original_method.__module__
#             except AttributeError:
#                 pass
# 
#         if inspect.ismethod(original_method):
#             new_mocked_method = utils.newmethod(
#                 new_mocked_method, self.mocked_obj
#             )
# 
#         if isinstance(original_method, staticmethod):
#             new_mocked_method = staticmethod(new_mocked_method)  # type: ignore[assignment]
#         elif isinstance(original_method, classmethod):
#             new_mocked_method = classmethod(new_mocked_method)  # type: ignore[assignment]
#         elif (
#             inspect.isclass(self.mocked_obj)
#             and inspect.isclass(original_method)  # TBC: Inner classes
#         ):
#             new_mocked_method = staticmethod(new_mocked_method)  # type: ignore[assignment]
# 
#         self.set_method(method_name, new_mocked_method)
# 
#     def stub(self, method_name):
#         try:
#             self.original_methods[method_name]
#         except KeyError:
#             original_method, was_in_spec = self.get_original_method(
#                 method_name)
#             if was_in_spec:
#                 # This indicates the original method was found directly on
#                 # the spec object and should therefore be restored by unstub
#                 self.original_methods[method_name] = original_method
#             else:
#                 self.original_methods[method_name] = None
# 
#             self.replace_method(method_name, original_method)
# 
#     def forget_stubbed_invocation(self, invocation):
#         assert invocation in self.stubbed_invocations
# 
#         if len(self.stubbed_invocations) == 1:
#             mock_registry.unstub(self.mocked_obj)
#             return
# 
#         self.stubbed_invocations.remove(invocation)
# 
#         if not any(
#             inv.method_name == invocation.method_name
#             for inv in self.stubbed_invocations
#         ):
#             original_method = self.original_methods.pop(invocation.method_name)
#             self.restore_method(invocation.method_name, original_method)
# 
#     def restore_method(self, method_name, original_method):
#         # If original_method is None, we *added* it to mocked_obj, so we
#         # must delete it here.
#         # If we mocked an instance, our mocked function will actually hide
#         # the one on its class, so we delete as well.
#         if (
#             not original_method
#             or not inspect.isclass(self.mocked_obj)
#             and inspect.ismethod(original_method)
#         ):
#             delattr(self.mocked_obj, method_name)
#         else:
#             self.set_method(method_name, original_method)
# 
#     def unstub(self):
#         while self.original_methods:
#             method_name, original_method = self.original_methods.popitem()
#             self.restore_method(method_name, original_method)
# 
#     # SPECCING
# 
#     def has_method(self, method_name):
#         if self.spec is None:
#             return True
# 
#         return hasattr(self.spec, method_name)
# 
#     def get_signature(self, method_name):
#         if self.spec is None:
#             return None
# 
#         try:
#             return self._signatures_store[method_name]
#         except KeyError:
#             sig = signature.get_signature(self.spec, method_name)
#             self._signatures_store[method_name] = sig
#             return sig


import pytest
from mockito.mock_registry import _Dict
from mockito.mocking import Mock




class TestCustomDictLike:

    def testAssignKeyValuePair(self):
        td = _Dict()
        obj = {}

# Path: mockito/mocking.py
# class Mock(object):
#     def __init__(self, mocked_obj, strict=True, spec=None):
#         self.mocked_obj = mocked_obj
#         self.strict = strict
#         self.spec = spec
# 
#         self.invocations = deque()  # type: Deque[RealInvocation]
#         self.stubbed_invocations = deque()  # type: Deque[invocation.StubbedInvocation]
# 
#         self.original_methods = {}
#         self._signatures_store = {}
# 
#     def remember(self, invocation):
#         self.invocations.appendleft(invocation)
# 
#     def finish_stubbing(self, stubbed_invocation):
#         self.stubbed_invocations.appendleft(stubbed_invocation)
# 
#     def clear_invocations(self):
#         self.invocations = deque()
# 
#     # STUBBING
# 
#     def get_original_method(self, method_name):
#         """
#         Looks up the original method on the `spec` object and returns it
#         together with an indication of whether the method is found
#         "directly" on the `spec` object.
# 
#         This is used to decide whether the method should be stored as an
#         original_method and should therefore be replaced when unstubbing.
#         """
#         if self.spec is None:
#             return None, False
# 
#         try:
#             return self.spec.__dict__[method_name], True
#         except (AttributeError, KeyError):
#             # Classes with defined `__slots__` and then no `__dict__` are not
#             # patchable but if we catch the `AttributeError` here, we get
#             # the better error message for the user.
#             return getattr(self.spec, method_name, None), False
# 
#     def set_method(self, method_name, new_method):
#         setattr(self.mocked_obj, method_name, new_method)
# 
#     def replace_method(self, method_name, original_method):
# 
#         def new_mocked_method(*args, **kwargs):
#             # we throw away the first argument, if it's either self or cls
#             if (
#                 inspect.ismethod(new_mocked_method)
#                 or inspect.isclass(self.mocked_obj)
#                 and not isinstance(new_mocked_method, staticmethod)
#             ):
#                 args = args[1:]
# 
#             return remembered_invocation_builder(
#                 self, method_name, *args, **kwargs)
# 
#         new_mocked_method.__name__ = method_name
#         if original_method:
#             new_mocked_method.__doc__ = original_method.__doc__
#             new_mocked_method.__wrapped__ = original_method  # type: ignore[attr-defined]
#             try:
#                 new_mocked_method.__module__ = original_method.__module__
#             except AttributeError:
#                 pass
# 
#         if inspect.ismethod(original_method):
#             new_mocked_method = utils.newmethod(
#                 new_mocked_method, self.mocked_obj
#             )
# 
#         if isinstance(original_method, staticmethod):
#             new_mocked_method = staticmethod(new_mocked_method)  # type: ignore[assignment]
#         elif isinstance(original_method, classmethod):
#             new_mocked_method = classmethod(new_mocked_method)  # type: ignore[assignment]
#         elif (
#             inspect.isclass(self.mocked_obj)
#             and inspect.isclass(original_method)  # TBC: Inner classes
#         ):
#             new_mocked_method = staticmethod(new_mocked_method)  # type: ignore[assignment]
# 
#         self.set_method(method_name, new_mocked_method)
# 
#     def stub(self, method_name):
#         try:
#             self.original_methods[method_name]
#         except KeyError:
#             original_method, was_in_spec = self.get_original_method(
#                 method_name)
#             if was_in_spec:
#                 # This indicates the original method was found directly on
#                 # the spec object and should therefore be restored by unstub
#                 self.original_methods[method_name] = original_method
#             else:
#                 self.original_methods[method_name] = None
# 
#             self.replace_method(method_name, original_method)
# 
#     def forget_stubbed_invocation(self, invocation):
#         assert invocation in self.stubbed_invocations
# 
#         if len(self.stubbed_invocations) == 1:
#             mock_registry.unstub(self.mocked_obj)
#             return
# 
#         self.stubbed_invocations.remove(invocation)
# 
#         if not any(
#             inv.method_name == invocation.method_name
#             for inv in self.stubbed_invocations
#         ):
#             original_method = self.original_methods.pop(invocation.method_name)
#             self.restore_method(invocation.method_name, original_method)
# 
#     def restore_method(self, method_name, original_method):
#         # If original_method is None, we *added* it to mocked_obj, so we
#         # must delete it here.
#         # If we mocked an instance, our mocked function will actually hide
#         # the one on its class, so we delete as well.
#         if (
#             not original_method
#             or not inspect.isclass(self.mocked_obj)
#             and inspect.ismethod(original_method)
#         ):
#             delattr(self.mocked_obj, method_name)
#         else:
#             self.set_method(method_name, original_method)
# 
#     def unstub(self):
#         while self.original_methods:
#             method_name, original_method = self.original_methods.popitem()
#             self.restore_method(method_name, original_method)
# 
#     # SPECCING
# 
#     def has_method(self, method_name):
#         if self.spec is None:
#             return True
# 
#         return hasattr(self.spec, method_name)
# 
#     def get_signature(self, method_name):
#         if self.spec is None:
#             return None
# 
#         try:
#             return self._signatures_store[method_name]
#         except KeyError:
#             sig = signature.get_signature(self.spec, method_name)
#             self._signatures_store[method_name] = sig
#             return sig


# Path: tests/my_dict_test.py
import pytest
from mockito.mock_registry import _Dict
from mockito.mocking import Mock





class TestCustomDictLike:

    def testAssignKeyValuePair(self):
        td = _Dict()
        obj = {}

        mock = Mock(None)