Is there a way in a pytest fixture to figure out what test is calling it?
I have tries with inspect but that returns the call_fixture_func ... conftest.py ...
@fixture(scope="function")
def resource(app_config):
curframe = inspect.currentframe()
caller = inspect.getouterframes(curframe, 2)[1][3]
resource = app_config.handler.get(caller)
yield resource
resource.finish_test()
... test file ...
@mark.smoke
def test_resource_is_happy(resource):
print(f"Test starting on {resource.name}")
....
thanks
Aucun commentaire:
Enregistrer un commentaire