I have a file structure similar to the following:
app/
|--- __init__.py
|--- module_under_test.py
test/
|--- test_module.py
I want to unittest a module in a package by using pytest. When I import the module in my test file, the code in the __init__.py gets executed. However I want to bypass the code in the __init__.py file because in __init__.py other external dependencies are used. One way I can think of is mocking all necessary objects in __init__.py by using patch.
What is the best practise to solve this problem? Thank you.