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
mock.patch decorating a generator returns a regular function. #71528
Comments
(at least in my case) I committed two tests before I realized the tests were not being run: https://github.com/nipy/nipype/blob/abe7920a051f1570ccce4b71f26f50102d6e4e12/nipype/testing/tests/test_utils.py#L23 I realized this afternoon, while writing some more tests, that tests with the patch decorator were all reported as "OK", even when I wanted them to fail. Turns out they aren't being run at all. I commented out all the yield statements, and the tests ran just as they should. I don't know exactly what is going on here, but might raising an error or warning be good here? Originally filed here: testing-cabal/mock#366 |
3.2 to 3.4 only get security fixes please provide a simple test that fails now and that you think should pass or at least warn. |
There are two related things here. Firstly, the generator's body will run without the patch (because the wrapping function has try: Secondly, the wrapping function is itself not a generator, and anything that introspects functions to see if they are generators will not detect the wrapped function as one - which is I suspect whats tripping nose up, but I haven't actually checked the nose code to see what its doing/expecting. |
Once fixed in CPython, we'll put the backport in mock, for folk using older Python's. |
I attached a file with 4 tests and the output. nosetests reports that all four tests were executed. In reality, only two tests were executed. |
output |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: