diff options
author | Roald de Vries <rdevries@thoughtworks.com> | 2016-10-06 17:03:44 -0300 |
---|---|---|
committer | Roald de Vries <rdevries@thoughtworks.com> | 2016-10-07 18:25:02 -0300 |
commit | f4d7541c9b6dcf67b57b13f7ca7434ec68eeb59c (patch) | |
tree | 8d50a54a9a8d5dd451253e55275f209f9df32b0a /service/test/support/mockito/__init__.py | |
parent | 4642cee939c08bfa809f55b6a85ffa773600eaf9 (diff) |
use test client in test case through composition instead of inheritance
Diffstat (limited to 'service/test/support/mockito/__init__.py')
-rw-r--r-- | service/test/support/mockito/__init__.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/service/test/support/mockito/__init__.py b/service/test/support/mockito/__init__.py index c8ffc55e..8589fac0 100644 --- a/service/test/support/mockito/__init__.py +++ b/service/test/support/mockito/__init__.py @@ -13,7 +13,7 @@ # # You should have received a copy of the GNU Affero General Public License # along with Pixelated. If not, see <http://www.gnu.org/licenses/>. -from mockito.invocation import AnswerSelector, CompositeAnswer +from mockito.invocation import AnswerSelector as OriginalAnswerSelector, CompositeAnswer class FunctionReturn(object): @@ -27,14 +27,14 @@ class FunctionReturn(object): return self.function_answer() -def thenAnswer(self, answer_function): - """mockito does not support the thenAnswer style. This method monkey patches it into the library""" - if not self.answer: - self.answer = CompositeAnswer(FunctionReturn(answer_function)) - self.invocation.stub_with(self.answer) - else: - self.answer.add(FunctionReturn(answer_function)) +class AnswerSelector(OriginalAnswerSelector): - return self + def thenAnswer(self, answer_function): + """mockito does not support the thenAnswer style. This method monkey patches it into the library""" + if not self.answer: + self.answer = CompositeAnswer(FunctionReturn(answer_function)) + self.invocation.stub_with(self.answer) + else: + self.answer.add(FunctionReturn(answer_function)) -AnswerSelector.thenAnswer = thenAnswer + return self |