Skip to content

Stubs for org.mockito.Mockito.doThrow incomplete

(seen because I used it and it failed in mypy)

class Mockito(ArgumentMatchers):
    ...
    @typing.overload
    @staticmethod
    def doThrow(class_: typing.Type[java.lang.Throwable]) -> org.mockito.stubbing.Stubber: ...
    @typing.overload
    @staticmethod
    def doThrow(class_: typing.Type[java.lang.Throwable], classArray: typing.List[typing.Type[java.lang.Throwable]]) -> org.mockito.stubbing.Stubber: ...
    @typing.overload
    @staticmethod
    def doThrow(throwableArray: typing.List[java.lang.Throwable]) -> org.mockito.stubbing.Stubber: ...
    ...

The definition of doThrow (and its family of methods) is at https://javadoc.io/doc/org.mockito/mockito-core/latest/org/mockito/Mockito.html#doThrow(java.lang.Throwable...), which has the following signature:

public static Stubber doThrow​(Throwable... toBeThrown)

This suggests that variable arguments aren't being handled correctly, and that the final stub should actually read:

def doThrow(*throwableArray: java.lang.Throwable) -> org.mockito.stubbing.Stubber: ...

(as per the PEP at https://peps.python.org/pep-0484/#arbitrary-argument-lists-and-default-argument-values)

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information