0
@pytest_fixture
def some_fix():
    return some_data

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

Captain
  • 123
  • 4
  • 11
  • it depend if said decorator offer access to the original function, where that decorator come from? – Copperfield Dec 02 '21 at 16:57
  • 1
    Remove the decorator? Create a new function without decorator? – IgorZ Dec 02 '21 at 16:58
  • Does this answer your question? [How to strip decorators from a function in Python](https://stackoverflow.com/questions/1166118/how-to-strip-decorators-from-a-function-in-python) – Peter Dec 02 '21 at 17:40

1 Answers1

1

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()
Florin C.
  • 593
  • 4
  • 13