561 | | ||I get {{{mockito.invocation.InvocationError: You tried to stub a method __len__ the object (<class 'mockito.mocking.mock.<locals>.Dummy'>) doesn't have.}}} ||Python typing around the built-in types (list, set, str, repr) is messy. If you stub a java List/Set, it translates to mock(typing.List/typing.Set). And those types do not have {{{___len___}}} causing the error. |
562 | | In these special cases you need to use mock(list)/mock(set). Try manual translation of these types. For example to mock {{{__repr__}}} you need {{{when2(myobj.__repr__).thenReturn("xx")}}}|| |
| 561 | ||I get {{{mockito.invocation.InvocationError: You tried to stub a method __len__ the object (<class 'mockito.mocking.mock.<locals>.Dummy'>) doesn't have.}}} ||Python typing around the built-in types (list, set, str, repr) is messy. If you stub a java List/Set, it translates to mock(typing.List/typing.Set). And those types do not have {{{___len___}}} causing the error. In these special cases you need to use mock(list)/mock(set). Try manual translation of these types. For example to mock {{{__repr__}}} you need {{{when2(myobj.__repr__).thenReturn("xx")}}}|| |