SubprocessPlugin¶
SubprocessPlugin
¶
Bases: BasePlugin
Subprocess interception plugin.
Patches subprocess.run and shutil.which globally. Uses reference counting so nested sandboxes work correctly, following the HttpPlugin pattern exactly.
Source code in src/bigfoot/plugins/subprocess.py
install
¶
No-op. Called to ensure plugin is registered before sandbox entry.
Access to any attribute of subprocess_mock triggers plugin creation via _SubprocessProxy.getattr. This method exists as a named no-op so tests that want the bouncer active without any mocks have an explicit API to call.
Source code in src/bigfoot/plugins/subprocess.py
mock_run
¶
Register a FIFO subprocess.run mock.
Calls are matched in registration order. An unmocked or out-of-order call raises UnmockedInteractionError immediately (bouncer guarantee).
Source code in src/bigfoot/plugins/subprocess.py
mock_which
¶
Register a shutil.which mock keyed by binary name.
Always-on: unregistered names are swallowed (return None) and recorded on the timeline, requiring assertion at teardown. Registered names return the configured value. required=False by default because tests often register more alternatives than will be hit in a given path.
Source code in src/bigfoot/plugins/subprocess.py
assert_run
¶
Assert the next subprocess.run interaction with all 4 fields.
Source code in src/bigfoot/plugins/subprocess.py
assert_which
¶
Assert the next shutil.which interaction with all 2 fields.
Source code in src/bigfoot/plugins/subprocess.py
activate
¶
Reference-counted class-level patch installation.