All Questions
2 questions
2
votes
2
answers
239
views
Why does unittest's `mock.patch.start` re-run the function in which the patcher is started?
Let's say we have two files:
to_patch.py
from unittest.mock import patch
def patch_a_function():
print("Patching!")
patcher = patch("to_be_patched.function")
patcher....
0
votes
0
answers
397
views
Patch global variable once in several modules
Imagine that we have a module one.py with some global variable glob_var=object().
Also I have some other modules on different levels that import glob_var using relative import, such as:
from .one.py ...