-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No longer can extract message from exceptions in 5+ versions #5579
Comments
assert 'blabla' in str(e.value) Haven't looked at release notes yet to see why but accessing the exception text changed slightly. |
@banderson5586 but why accessing the error message using pytest is different from the way it's done in python 2/3 ? it does not make any sense to me. |
Hi, Here's the related CHANGELOG entry:
So it was mostly to avoid confusion. Note that Here are the docs for As can be seen in the docs, |
Understood. This change is probably gonna break a ton of unit tests ... |
Let's see, we are hopíng not, as this was not really documented behavior. I'm closing this for now, feel free to follow up with further questions though. |
related to pytest-dev/pytest#5579 Signed-off-by: Francesco De Martino <[email protected]>
related to pytest-dev/pytest#5579 Signed-off-by: Francesco De Martino <[email protected]>
related to pytest-dev/pytest#5579 Signed-off-by: Francesco De Martino <[email protected]>
related to pytest-dev/pytest#5579 Signed-off-by: Francesco De Martino <[email protected]>
@nicoddemus I understand the change but it did smash a good bit of my test suite out of the blue when my CI suite pulled v5 instead of v4.X. I didn't realize I was using undocumented behavior which in the end is on me but I suspect several others will get hit in the face by this as well. Maybe adding an extra note somewhere that statements such as |
I don't know @stadelmanma how much time you spent in order to find this issue but I still think it would make more sense to support the old behavior and avoid breaking uncountable tests. |
Sorry this caused problems, we usually try to avoid that as much as possible. I would be glad to review/merge a PR with improved docs and/or to the README! 👍 |
(Just for information / as a data point: I've also seen this rather often in test suites (but not my own ;)) upgrading to pytest 5 by now. But usually without much effort (AFAICS).) |
Broke quite a few of our tests too, I agree with @stadelmanma's comment (#5579 (comment)). I didn't connect the CHANGELOG content to this consequence either. Edit: README -> CHANGELOG |
See: pytest-dev/pytest#5579 Signed-off-by: William Woodall <[email protected]>
I agree the README would provide better visibility but I don't think this kind of notice fits well on it. The CHANGLOG is the more appropriate place and maybe somewhere in the general docs but I'll need to scan over those tomorrow to see if any pages make sense. @cscetbon When I saw all my tests break I took the following steps:
All in all it only took me about 5-10 minutes to figure out the problem since you already found it. I imagine most devs will probably take the same steps unless they've never been burned by a dependency changed. (Eventually Google SEO will probably funnel people here directly) @nicoddemus, perhaps there are a few options to allow this behavior back:
|
Sorry, README was a typo, I meant CHANGELOG too. |
Definitely meant CHANGELOG as well, not README, sorry about that.
Those are all sensible solutions, thanks, but I'm not sure adding a new option (and now having to maintain it until at least pytest 6.0) will actually help things. I believe it will probably only add to the confusion. |
Neat. I guess you’re right, that issue helps understanding it faster. I’m not sure everybody will look into the dependencies but yeah Google will hopefully funnel them here.
Could be interesting and that’s usually what I expect from a breaking change ^. I wouldn’t vote for a config option though. It could be deprecated but supported for a few versions before being unsupported. |
Agree, in retrospect I think that would be the best course of action. At the time we didn't thought it would bring much breakage... 😞 I opened #5648 to at least make that more explicit on the changelog. |
See: pytest-dev/pytest#5579 Signed-off-by: William Woodall <[email protected]>
…ts to true"" (#277) * Revert "Revert "[execute_process] emulate_tty configurable and defaults to true (#265)" (#276)" This reverts commit 15af530. * add option to strip ansi escape sequences from output in launch_testing Signed-off-by: William Woodall <[email protected]> * move registration of event handlers before including test file Signed-off-by: William Woodall <[email protected]> * replace \r\n with \n too, because you get this in emulated tty mode Signed-off-by: William Woodall <[email protected]> * fix a new test failure due a change in how pytest represents exceptions See: pytest-dev/pytest#5579 Signed-off-by: William Woodall <[email protected]> * refactor to not use YAML in eval of emulate_tty option Signed-off-by: William Woodall <[email protected]> * fix typo Signed-off-by: William Woodall <[email protected]> * refactor emulate_tty tests and test constructor argument Signed-off-by: William Woodall <[email protected]> * change default for emulate_tty to be False and fix warnings Signed-off-by: William Woodall <[email protected]>
…ts to true"" (ros2#277) * Revert "Revert "[execute_process] emulate_tty configurable and defaults to true (ros2#265)" (ros2#276)" This reverts commit 15af530. * add option to strip ansi escape sequences from output in launch_testing Signed-off-by: William Woodall <[email protected]> * move registration of event handlers before including test file Signed-off-by: William Woodall <[email protected]> * replace \r\n with \n too, because you get this in emulated tty mode Signed-off-by: William Woodall <[email protected]> * fix a new test failure due a change in how pytest represents exceptions See: pytest-dev/pytest#5579 Signed-off-by: William Woodall <[email protected]> * refactor to not use YAML in eval of emulate_tty option Signed-off-by: William Woodall <[email protected]> * fix typo Signed-off-by: William Woodall <[email protected]> * refactor emulate_tty tests and test constructor argument Signed-off-by: William Woodall <[email protected]> * change default for emulate_tty to be False and fix warnings Signed-off-by: William Woodall <[email protected]>
- Extract the original exception from the ExceptionInfo object, this changed in Pytest 5, see pytest-dev/pytest#5579
I can't extract the message of an exception using str(my_exception) when using pytest 5+. Here is an example :
That test succeeds in previous versions (4.6.4 for instance)
I've been able to test it using the following example :
The text was updated successfully, but these errors were encountered: