Код: Выделить всё
# defined in headache/__init__.py
problem = Problem()
Код: Выделить всё
# this is foo.py
from headache import problem
class Foo:
# uses `problem` object
Код: Выделить всё
# this is bar.py
from headache import problem
class Bar:
# uses `problem` object
Код: Выделить всё
unittest.mock.patch(target="foo.problem", new=...)
Код: Выделить всё
unittest.mock.patch(target="bar.problem", new=...)
Подробнее здесь: https://stackoverflow.com/questions/787 ... -in-python