I'm trying to use pytest-bdd with unittest.mock - to be more precise - I have to patch a class (let's say 'MyClass') from a module_XXX in one of the steps. But the issues is that unittest.mock uses decorators to provide patched classes via method arguments. But pytest-bdd always considers arguments as fixtures and obviously cannot find them. Here is the code:
@then('it should call my class method_YYY')
@patch('module_XXX.MyClass')
def it_should_call_my_class_method_yyy(MyClassMock):
module_XXX.__init__("__main__")
assert MyClassMock.called
Is it possible to disable "argument is a fixture" pytest-bdd feature? Is pytest-bdd compatible with unittest.mock? It seems like, the documentation of pytest-bdd says nothing about such cases.
Hi,
I'm trying to use pytest-bdd with unittest.mock - to be more precise - I have to patch a class (let's say 'MyClass') from a module_XXX in one of the steps. But the issues is that unittest.mock uses decorators to provide patched classes via method arguments. But pytest-bdd always considers arguments as fixtures and obviously cannot find them. Here is the code:
Is it possible to disable "argument is a fixture" pytest-bdd feature? Is pytest-bdd compatible with unittest.mock? It seems like, the documentation of pytest-bdd says nothing about such cases.
-Thanks