Repository navigation
Disable monkey patching "mock" when --tb is set to native - #46
Conversation
| ``repr`` string as well as related assertion failure messages. | ||
| Thanks `@jurko-gospodnetic`_ for the PR (`#40`_). | ||
|
|
||
| * Monkey patching is automatically disabled with the ``--tb=native`` option. The underlying |
There was a problem hiding this comment.
Hmm I should change this to:
Monkey patching ``mock`` module for friendlier tracebacks is automatically disabled
with the ``--tb=native`` option.
There was a problem hiding this comment.
Yep, thanks for the reminder. 😁
|
@blueyed did you get a chance of trying this out? 😁 |
|
Thanks, I have not tried it yet - sorry. Would it make sense to display a warning/info message in case it gets automatically disabled? |
Hmmm it does make sense, not sure how to display this warning though. How about: |
👍 Also the PR works in general as advertised. |
|
@The-Compiler what do you think? 😁 |
| assert result.ret == 1 | ||
| assert 'Traceback (most recent call last)' in result.stdout.str() | ||
| assert 'During handling of the above exception' not in result.stdout.str() | ||
| assert 'Differing items:' not in result.stdout.str() |
There was a problem hiding this comment.
Hmm, maybe the test should make sure there is actually no second traceback (like reported in #44)?
|
FWIW I don't really see a value in the warning. The monkeypatching is never something you'd enable explicitly, right? I'd imagine you either let it happen by default, or set If I'm using |
|
Note to self: mention this feature in |
Hmm you got a point, it is enabled by default so the user won't "try to use it and it won't work", which I agree would be confusing. @blueyed perhaps a note on the README is enough?
I didn't know at the time if that monkeypatching could interfere with something else in more complex test suites, so I decided to put that option in there more like a preemptive measure. |
Would be fine with me. |
|
Thanks guys! |
The mechanism we use to hide traceback entries from the
mockmodule does not work on native tracebacks anyway, so it makes sense to automatically disable it in that situation.This also takes care of the duplicated tracebacks on Python 3.5. @blueyed could you try this out and tell what do you think?
Fix #44