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:
assignee=Noneclosed_at=Nonecreated_at=<Date2021-07-23.23:38:41.484>labels= ['3.8', 'type-feature', 'library']
title='unittest.mock.patch does not work as a decorator on generator functions'updated_at=<Date2021-07-24.00:57:01.742>user='https://github.com/gmjw'
unitest.mock.patch does not work well when applied as a decorator to a function which is a generator.
It results in the function being changed from a generator function (co_flags 99) to a non-generator (co_flag 31) and the patch is not applied.
[I have a MWE, attached, and fairly simple fix, to the file mock.py, which I will put up as a PR in due course. This is the first time I've submitted a bug or PR, so apologies if I've not done this particularly well.]
Activity
gmjw commented on Jul 23, 2021
unitest.mock.patch does not work well when applied as a decorator to a function which is a generator.
It results in the function being changed from a generator function (co_flags 99) to a non-generator (co_flag 31) and the patch is not applied.
[I have a MWE, attached, and fairly simple fix, to the file mock.py, which I will put up as a PR in due course. This is the first time I've submitted a bug or PR, so apologies if I've not done this particularly well.]