MCPcopy Index your code
hub / github.com/python/cpython / __exit__

Method __exit__

Lib/unittest/mock.py:1640–1662  ·  view source on GitHub ↗

Undo the patch.

(self, *exc_info)

Source from the content-addressed store, hash-verified

1638 raise
1639
1640 def __exit__(self, *exc_info):
1641 """Undo the patch."""
1642 if not self.is_started:
1643 return
1644
1645 if self.is_local and self.temp_original is not DEFAULT:
1646 setattr(self.target, self.attribute, self.temp_original)
1647 else:
1648 delattr(self.target, self.attribute)
1649 if not self.create and (not hasattr(self.target, self.attribute) or
1650 self.attribute in ('__doc__', '__module__',
1651 '__defaults__', '__annotations__',
1652 '__kwdefaults__')):
1653 # needed for proxy objects like django settings
1654 setattr(self.target, self.attribute, self.temp_original)
1655
1656 del self.temp_original
1657 del self.is_local
1658 del self.target
1659 exit_stack = self._exit_stack
1660 del self._exit_stack
1661 self.is_started = False
1662 return exit_stack.__exit__(*exc_info)
1663
1664
1665 def start(self):

Callers 2

__enter__Method · 0.95
stopMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected