When I run my pytest and mock patch a global variable in the python file that has a function call assigned to capture the output, I'm unable to mock it (I dont want to actually execute the function during tests). I find that the function is still getting called. How can I prevent it from being called?
file 1: /app/file1.py
def some_func():
return "the sky is like super blue"
file 2: /app/file2.py
from app.file1 import some_func
VAR1 = some_func()
file 3: /tests/app/test_file2.py
import mock
import pytest
from app.file2 import VAR1
@mock.patch('app.file2.VAR1', return_value=None)
def test_file_2_func(baba_fake_val):
print('made it to my test :)'
print(VAR1)