You could attempt something like what is mentioned in
https://docs.python.org/3/library/unittest.mock-examples.html#partial-mocking
See below.
"Joshua J. Kugler" writes:
> Hello! I am using Mock to raise an exception in an function as a side
> effect.
> However, Mock is completely redefining
Hello! I am using Mock to raise an exception in an function as a side effect.
However, Mock is completely redefining the exception itself turning it in to a
MagickMock object, which generates the Python exception
TypeError: catching classes that do not inherit from BaseException is not
allowed