Search code examples
pythonpytestdecoratorpython-decoratorsfixtures

How to bypass pytest fixture decorator?


@pytest_fixture
def some_fix():
    return some_data

I want to call this some_fix function directly. How do I bypass pytest fixture decorator?


Solution

  • Applying any trick that bypasses the decorator has the same value as decrementing a number after incrementing it. The cleanest solution would be to define two functions:

    def plain_function():
        # call this function when you need to bypass decorator
        pass
    
    
     @pytest.fixture
     def simlar_fixture():
        return plain_function()