I have a module that imports another module like this:
#main-file.py
import src.FetchFunction.video_service.fields.urls as urls
def some_func():
return urls.fetch()
now I want to test this file like this:
import unittest
import src.FetchFunction.video_service.fields.urls as urls
from unittest.mock import MagicMock
class MainFileTest(unittest.TestCase):
def test_example(self):
urls.fetch = MagicMock(return_value='mocked_resp')
assertSomething()
this part works well and does what I want. BUT this affects other tests file... I mean I have other tests that use the "urls.fetch" and now instead of getting the proper flow they get the above mocked response.
Any idea?
- quite sure its not related but Im using
pytest
to run my tests