ripe-cpu-85141
08/16/2022, 4:04 PM@pytest.fixture(autouse=True)
def dont_do_this(mocker):
mocker.patch("my.module.class.method")
and Pants doesn't seem to add my/module.py
in the dependencies even with
[python-infer]
string_imports = true
Am I missing something or should I manually add those deps in my BUILD file?bitter-ability-32190
08/16/2022, 4:07 PMpytest-mock
in your pytest
extra_requirements
?
Then it's in every test execution/sandbox: https://www.pantsbuild.org/v2.13/docs/python-test-goal#pytest-version-and-pluginsripe-cpu-85141
08/16/2022, 4:09 PMpytest-mock
in the config.bitter-ability-32190
08/16/2022, 4:09 PM./pants dependencies path/to/conftest.py
say?ripe-cpu-85141
08/16/2022, 4:10 PMbitter-ability-32190
08/16/2022, 4:10 PMbitter-ability-32190
08/16/2022, 4:11 PMmy.module
therefore does it really matter if we patch it or not? They aren't using it.
⢠Test does, which therefore the patching does its thangripe-cpu-85141
08/16/2022, 4:13 PMripe-cpu-85141
08/16/2022, 4:15 PMconftest.py
but I think that is a pretty common use case so I was wondering if I am missing something.bitter-ability-32190
08/16/2022, 4:27 PMripe-cpu-85141
08/16/2022, 6:28 PMbitter-ability-32190
08/16/2022, 6:28 PMripe-cpu-85141
08/16/2022, 6:29 PMbitter-ability-32190
08/16/2022, 6:29 PMbitter-ability-32190
08/16/2022, 6:29 PMtry/except
bitter-ability-32190
08/16/2022, 6:30 PMconftest.py
in your BUILD.pants
ripe-cpu-85141
08/16/2022, 6:30 PMripe-cpu-85141
08/16/2022, 6:31 PMripe-cpu-85141
08/16/2022, 6:32 PMripe-cpu-85141
08/16/2022, 7:56 PMwith contextlib.suppress(ModuleNotFoundError):
mocker.patch(...)
works like a charm šbitter-ability-32190
08/16/2022, 7:57 PM