You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mockito-python
is it possible to mock methods with the @property annotation or
propertys and propertys calculated by functions
regards
gary
Serhiy Oplakanets
unread,
Jul 27, 2010, 3:20:57 AM7/27/10
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mockito-python
In short: NO.
You can mock setters and deleters, but not getters, as current
implementation doesn't allow that.
However I'm not sure this is feasible to do with mockito. Did you
consider creating a mock class by hands?
gary
unread,
Jul 27, 2010, 3:54:42 AM7/27/10
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mockito-python
On Jul 27, 8:20 am, Serhiy Oplakanets <ser...@oplakanets.com> wrote:
> In short: NO.
> You can mock setters and deleters, but not getters, as current
> implementation doesn't allow that.
ok thats an interesting comment what is the shortcoming that doesn't
allow mocking of getters...
> However I'm not sure this is feasible to do with mockito. Did you
> consider creating a mock class by hands?
Ah I have just started to use mockito to avoid that ;-)
regards and manyt hanks for the comments
gary
Serhiy Oplakanets
unread,
Jul 27, 2010, 4:02:16 AM7/27/10
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mockito-python
> ok thats an interesting comment what is the shortcoming that doesn't
> allow mocking of getters...
Getters are not really executed as functions, and mockito can answer
only to call (parentheses)
This is both due to properties implementation and mockito
implementation. Check out the code.
> Ah I have just started to use mockito to avoid that ;-)
Wrong way to go if you ask me. One should always prefer using hand-
rolled mocks. They're always closer to domain model and easier to read/
understand.
Your mocking tool should only help you in cases when hand-rolled mocks
become complex and hard to implement.