MockPlugin¶
MockPlugin
¶
Bases: BasePlugin
Core mock plugin: intercepts method calls on named proxy objects.
Source code in src/tripwire/_mock_plugin.py
create_import_site_mock
¶
Create an ImportSiteMock. Registration happens in _BaseMock.init.
create_object_mock
¶
Create an ObjectMock. Registration happens in _BaseMock.init.
get_or_create_proxy
¶
Return an existing MockProxy for name, or create a new one.
If wraps is provided and a proxy already exists, update its wraps attribute (e.g., spy() called after mock()). If no proxy exists, create a new one with wraps set.
Source code in src/tripwire/_mock_plugin.py
matches
¶
Return True if all expected fields match the interaction's details.
Source code in src/tripwire/_mock_plugin.py
format_interaction
¶
One-line description: '[MockPlugin] MockName.method_name(first_arg_preview)'.
Source code in src/tripwire/_mock_plugin.py
format_mock_hint
¶
Copy-pasteable code to configure a mock for this interaction.
Source code in src/tripwire/_mock_plugin.py
format_unmocked_hint
¶
Copy-pasteable code snippet for mocking a call that had no side effect.
Source code in src/tripwire/_mock_plugin.py
format_assert_hint
¶
Copy-pasteable code to assert this interaction.
Source code in src/tripwire/_mock_plugin.py
assertable_fields
¶
Return the field names required in **expected when asserting a mock interaction.
Adapts based on interaction content: - Standard mock calls: {args, kwargs} - .raises() side effects: {args, kwargs, raised} - Spy returned: {args, kwargs, returned} - Spy raised: {args, kwargs, raised}
Source code in src/tripwire/_mock_plugin.py
get_unused_mocks
¶
Return MockConfig objects that are required=True and still in the queue (never consumed).
Source code in src/tripwire/_mock_plugin.py
format_unused_mock_hint
¶
Hint for an unused mock: show registration traceback and how to suppress.