pytest-mock (or unittest.mock) wraps the dependency in a fixture; calls happen on the mock. In production the same code calls the real dependency. The test should not need prod credentials, network, or time. Mock at the BOUNDARY (HTTP, DB, file), not deep inside business logic.
conftest.py: pytest fixture returns a Mock(spec=requests.Session).
service.process(session=mocked_session, …) - the function takes its dependency as an argument.
Asserting: mocked_session.post.assert_called_once_with(expected_url, json=payload).
test fixture -> Mock(spec=Session)
service(session=mocked)
assert mocked_session.post.assert_called_once_with(...)
Inject dependencies, then mock them at the boundary. Easier to test, easier to reuse.