0

I have a number of tests that have the same feature file format, but pass across different arguments and assert different json responses so I want to use the scenarios decorator over scenario. The decorator I am trying to use is:

@scenarios("../../features/errors.feature")

When I try to use scenarios I get the following error from which I am not really able to work out what exactly is the issue:

==================================== ERRORS ====================================
_______ ERROR collecting functional/tests/test_api/test_api_error.py ________
src/test/functional/tests/test_api/test_api_error.py:17: in <module>
    def get_data(v4_auth, get_url, from_date, to_date):
E   TypeError: 'NoneType' object is not callable
=========================== short test summary info ============================
ERROR src/test/functional/tests/test_api/test_api_error.py - TypeError: 'N...
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.11s ===============================

If I use the scenario decorator and provide a stubbed method with pass for each scenario in the feature file then this works fine but now I have a lot of essentially redundant functions just to declare the scenarios.

For example:

@scenario(
    "../../features/error.feature",
    "Retrieve data with an invalid from date format",
)
def invalid_from_date():
    pass

@scenario(
    "../../features/errors.feature",
    "Retrieve data with an invalid to date format",
)
def invalid_to_date():
    pass

@scenario(
    "../../features/errors.feature",
    "Retrieve data with all invalid params",
)
def invalid_params():
    pass

When using the scenario decorator all fixtures work fine and the tests all pass, I thought from reading the documentation that all I need do is to use the scenarios decorator in place of this.

The line it falls over at is always the declaration of the first function it tries to call.

berimbolo
  • 3,319
  • 8
  • 43
  • 78
  • 1
    `scenarios` is not an annotation but you should call it directly in your test module: `scenarios("../../features/errors.feature")`. See https://pytest-bdd.readthedocs.io/en/stable/#scenarios-shortcut – mattefrank Mar 04 '21 at 11:56
  • From memory I was doing this, just calling it and got the error described above. – berimbolo Mar 04 '21 at 12:54

0 Answers0