Assume pip install pytest-mock or poetry add pytest-mock
def test_me(mocker):
mocker.patch(
"module1.module2.module3.function", return_value=value
)Be careful with from module1.module2 import fn statement, see link
pip install pytest-snapshotdef test_me(snapshot):
snapshot.assert_match(output)If pandas dataframe, then use output.to_csv() since assert_match() accepts strings, not bytes
pytest --snapshot-updatepython -m SimpleHTTPServer <port_number> -d <dir>
add dev deps
poetry add --group dev deptry
set in-project env (folder .venv will be within the project)
poetry config virtualenvs.in-project true