pytest-dev / unittest2pytest

helps rewriting Python `unittest` test-cases into `pytest` test-cases
GNU General Public License v3.0
128 stars 27 forks source link

Handle self.assertRaises being used as context manager. #2

Closed EnTeQuAk closed 8 years ago

The-Compiler commented 8 years ago

And here we meet again :wink:

Seems like this broke the tests according to Travis - I also guess a added test for this scenario would be welcome.

(PS: https://www.webshox.org/ has a redirect loop, I guess that's unintended?)

EnTeQuAk commented 8 years ago

Hey! :smiley: Yeah, I'll add some test and will run the other tests, I kinda just ran it against a bigger project and found that sufficient for now. Stay tuned.

htgoebel commented 8 years ago

The fixes for context-handlers should better go into a fixer of its own, matching on with .... This is much more reliable then testing for unittest.case._sentinel. And it could easily be used for the other context-handlers which test e.g. the exception message (see https://pytest.org/latest/assert.html#assertions-about-expected-exceptions)

EnTeQuAk commented 8 years ago

Sounds good to me @htgoebel, especially for python3 the _sentinel check doesn't work so I will change that.

RonnyPfannschmidt commented 8 years ago

@adamchainz how did you en-cooperate the changes of this one (at second glance it seems like i should have merged this one first for correct attribution)

adamchainz commented 8 years ago

I took half of it, I didn't find the _sentinel was defined when I looked on Python 2 or 3 so I had to rewrite with None. Also the whitespace changes weren't required.

RonnyPfannschmidt commented 8 years ago

ok, i believe its fine as is

@EnTeQuAk ping me in case you disagree

adamchainz commented 8 years ago

I'm happy to rebase and create a branch that adds @EnTeQuAk as a contributor by unmerging part of my commit and merging his

On 25 May 2016 at 13:43, Ronny Pfannschmidt notifications@github.com wrote:

ok, i believe its fine as is

@EnTeQuAk https://github.com/EnTeQuAk ping me in case you disagree

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/pytest-dev/unittest2pytest/pull/2#issuecomment-221563747

Adam

RonnyPfannschmidt commented 8 years ago

in case he asks for it, i'd appreciate if you follow up with that

thanks for the work