Relative Content

Tag Archive for pythonpytestfixturesmonkeypatchingconftest

pytest conftest – defining fixtures with variable import paths

I am testing functions from different modules that use an imported helper function from helpers.py. I am monkeypatching this helper function in each module function’s test (please see below). I would like to put setup_do_thing() and mock_do_thing() in a conftest.py file to cut down on repetition and remove general_mocks.py, but am unable to do this due to the different import paths supplied to monkeypatch.setattr() in test_module_1.py and test_module_2.py.