Remove a method call from the group. If the method is not in the set, an UnexpectedMethodCallError will be raised. Args: mock_method: a mock method that should be equal to a method in the group. Returns: The mock method from the group Raises: UnexpectedMetho
(self, mock_method)
| 1221 | self._methods.append(mock_method) |
| 1222 | |
| 1223 | def MethodCalled(self, mock_method): |
| 1224 | """Remove a method call from the group. |
| 1225 | |
| 1226 | If the method is not in the set, an UnexpectedMethodCallError will be |
| 1227 | raised. |
| 1228 | |
| 1229 | Args: |
| 1230 | mock_method: a mock method that should be equal to a method in the group. |
| 1231 | |
| 1232 | Returns: |
| 1233 | The mock method from the group |
| 1234 | |
| 1235 | Raises: |
| 1236 | UnexpectedMethodCallError if the mock_method was not in the group. |
| 1237 | """ |
| 1238 | |
| 1239 | # Check to see if this method exists, and if so, remove it from the set |
| 1240 | # and return it. |
| 1241 | for method in self._methods: |
| 1242 | if method == mock_method: |
| 1243 | # Remove the called mock_method instead of the method in the group. |
| 1244 | # The called method will match any comparators when equality is checked |
| 1245 | # during removal. The method in the group could pass a comparator to |
| 1246 | # another comparator during the equality check. |
| 1247 | self._methods.remove(mock_method) |
| 1248 | |
| 1249 | # If this group is not empty, put it back at the head of the queue. |
| 1250 | if not self.IsSatisfied(): |
| 1251 | mock_method._call_queue.appendleft(self) |
| 1252 | |
| 1253 | return self, method |
| 1254 | |
| 1255 | raise UnexpectedMethodCallError(mock_method, self) |
| 1256 | |
| 1257 | def IsSatisfied(self): |
| 1258 | """Return True if there are not any methods in this group.""" |
nothing calls this directly
no test coverage detected