Mario Corchero <marioc...@gmail.com> 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 <rep...@bugs.python.org>
<https://bugs.python.org/issue38757>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to