Relative Content

Tag Archive for pythonpytest

Is there a way to require Pytest to reload imports in a test file?

TL;DR: I would like Pytest to reload imports in certain files when it runs those tests. Some of the imports in my code base have side effects that I need to control at test time. The behavior would basically be like importlib.reload for any module in the test file. Is this possible?

Mocking a nested function call with pytest

If I have a function, A1, that is being tested, and that function imports and calls function B1, which itself calls B2 from the same file, how do I mock function B2?