Lemmons/pytest-raises

AttributeError setting outcome.excinfo

Closed this issue · 3 comments

I have recently been digging into how pytest.marks.raises gets parametrized for an issue peripheral to the one I am reporting here. But additionally I found that the pytests (the ones inside pytest-raises) are failing for me with the following (abbreviated) error:

>                           outcome.excinfo = excinfo[:2] + (traceback, )
E                           AttributeError: can't set attribute

This appears to be related to the pluggy package, in which excinfo is a read-only property. I have tried changing the code to use the internal attribute 'outcome._excinfo', and it seems to fix the error, but I am not certain this is the right approach.

Have you, the project maintainers, experienced this problem? And if so, have you a plan for fixing this in the reasonably near future?

I am using Python 2.7.15 (Anaconda) with the following pytest versions:

$ conda list |grep -i pytest
pytest                    3.8.2                 py27_1000    conda-forge
pytest-cov                2.6.0                      py_0    conda-forge
pytest-raises             0.9                       <pip>
pytest-timeout            1.2.1                      py_0    conda-forge

And I also decided to check out the newest pytest-raises to see if there were any differences in behavior. There were none.

Are you able to provide a minimal example for this? With #13 merged you may no longer have issues, can you try with the master branch installed?

If it works now it would be really helpful to know what caused it for you so we can add a test case. I linked an issue from that PR with pytest, but if you're use case is compact I can migrate that issue to pluggy. Sometimes you can set outcome.excinfo, but sometimes you cannot. It's pretty confusing...

@svenevs: ok, I just pulled the latest master, and a bunch of commits came in, presumably #13, that I did not have before, and the pytest-raises tests are now passing. So that is great.

To your question of what caused it, probably this PR not quite included in the master pull, combined with me using a newer version of pytest, and specifically pluggy. Pluggy is a separate package, but it is part of pytest-dev. So I would expect their respective releases, and their features, to track pretty closely. I can't be sure when pluggy decided to make excinfo a read-only property because when I performed a 'conda update pytest', or some such command, pluggy was very likely updated as a dependency of pytest. (it wouldn't be too hard to go through the pluggy commits, I suppose)

To your comment about adding a test case, mainly it was the existing test cases inside pytest-raises that were failing for me. However there was one feature I noticed that you are not testing yet. And I'm not sure if you would find it to be truly useful, but I will describe it in another issue.

But as for the problem, I think it is fixed for me. And I pip reinstalled pytest-raises with the new 0.10 release, and it is passing for my project as well. Thank you so much for that. The only question I still have is this; do you have any plans to make a release for conda-forge? It's not really a big problem for me. It would simply be a convenience.

I don't have any plans for this, but you (or anyone else) are welcome to submit a pr with the needed updates and I'll be happy to work with you to get it merged.