-
Notifications
You must be signed in to change notification settings - Fork 106
Open
Labels
bugneeds-fixGood PR with failing test case, needs a fix implementedGood PR with failing test case, needs a fix implemented
Description
Howdy!
I've found that mixing Python's unittest.mock.patch decorator with parameterized.expand leads to unfortunate side-effects.
@parameterized.expand([("x", "y"),])
@patch("foo")
def test_bar(foo, x, y):
passWill lead to UnboundLocalError: local variable 'patching' referenced before assignment (at unittest\mock.py:1181).
I'm sure this is due to the nature of how expand generates test cases.
There's a workaround, which is use patch as a context manager in the test body. However, I'd still love to use both as decorators for all that delicious syntactic sugar and saved whitespace 😄.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugneeds-fixGood PR with failing test case, needs a fix implementedGood PR with failing test case, needs a fix implemented