Skip to content

It's not possible to disable "argument is a fixture" behavior (pytest-bdd + unittest.mock) #330

Open
@psxvoid

Description

@psxvoid

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:

@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.

-Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions