Provide custom logic for mocking classes that support item assignment. Args: key: Key to set the value for. value: Value to set. Returns: Expected return value in replay mode. A MockMethod object for the __setitem__ method that has already been called if not in rep
(self, key, value)
| 425 | self._expected_calls_queue == rhs._expected_calls_queue) |
| 426 | |
| 427 | def __setitem__(self, key, value): |
| 428 | """Provide custom logic for mocking classes that support item assignment. |
| 429 | |
| 430 | Args: |
| 431 | key: Key to set the value for. |
| 432 | value: Value to set. |
| 433 | |
| 434 | Returns: |
| 435 | Expected return value in replay mode. A MockMethod object for the |
| 436 | __setitem__ method that has already been called if not in replay mode. |
| 437 | |
| 438 | Raises: |
| 439 | TypeError if the underlying class does not support item assignment. |
| 440 | UnexpectedMethodCallError if the object does not expect the call to |
| 441 | __setitem__. |
| 442 | |
| 443 | """ |
| 444 | setitem = self._class_to_mock.__dict__.get('__setitem__', None) |
| 445 | |
| 446 | # Verify the class supports item assignment. |
| 447 | if setitem is None: |
| 448 | raise TypeError('object does not support item assignment') |
| 449 | |
| 450 | # If we are in replay mode then simply call the mock __setitem__ method. |
| 451 | if self._replay_mode: |
| 452 | return MockMethod('__setitem__', self._expected_calls_queue, |
| 453 | self._replay_mode)(key, value) |
| 454 | |
| 455 | |
| 456 | # Otherwise, create a mock method __setitem__. |
| 457 | return self._CreateMockMethod('__setitem__')(key, value) |
| 458 | |
| 459 | def __getitem__(self, key): |
| 460 | """Provide custom logic for mocking classes that are subscriptable. |
nothing calls this directly
no test coverage detected