< pre class="lang-py Prettyprint-override">
Код: Выделить всё
class MyClass:
def my_method(self):
from somewhere import the_thing
x = the_thing()
return x + 4
Код: Выделить всё
from unittest import TestCase
from unittest.mock import patch
class MyTestCase(TestCase):
@patch("path.to.my.module.the_thing")
def test_stuff(self):
...
Подробнее здесь: https://stackoverflow.com/questions/761 ... -or-method