Mario Corchero <> added the comment:

The reason why it seems that "no arguments are beeing passed" is because the 
exception is not being raised by you, but by mock itself when the exception is 
trying to be created. When an exception type is passed as side_effect, the mock 
modules raises such exception on the callable (the creation of the initial 
exception) To confirm this, just try removing the "raise" and leave the 
creation of the exception only.

I'd suggest that you use `wraps` rather than `side_effect`. That will make your 
example work.

Alternatively, if you need to use `side_effect`, you can use a wrapper so mock 
won't raise an exception when it sees that one:


def wrapper(*args, **kwargs):
    return MockError(*args, **kwargs)

patcher = patch('__main__.ProductionError', side_effect=wrapper)


I think this can be closed as a non-issue.


Python tracker <>
Python-bugs-list mailing list

Reply via email to