with mock.patch(
"mf_system.models.mf_article.MfSystemArticle._relate_with_text",
side_effect=TestException()
):
with mock.patch(
"mf_system.models.mf_article.MfSystemArticle.load_file",
return_value='test_file_name'
):
with mock.patch(
"tools.load_file.delete_file", return_value=1
) as mock_file:
try:
......
from contextlib import nested
with nested(mock.patch(...), mock.patch(...), ...):
...
тутwith mock.patch(...), mock.patch(...), ...:
...