Answer the question
In order to leave comments, you need to log in
How to simplify the design?
Something tells me that such a design can be simplified.
It can't be that python won't have a prettier notation for this.
(here I hang mocks on class methods)
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:
......
Answer the question
In order to leave comments, you need to log in
from contextlib import nested
with nested(mock.patch(...), mock.patch(...), ...):
...
herewith mock.patch(...), mock.patch(...), ...:
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question