breezy-electrician-41537
05/04/2024, 11:29 AMpants test tests::
seems to fail. I have a pytest which uses the following:
def dict_parametrize(data, **kwargs):
args = list(list(data.values())[0].keys())
formatted_data = [[item[a] for a in args] for item in data.values()]
ids = list(data.keys())
return pytest.mark.parametrize(args, formatted_data, ids=ids, **kwargs)
def file_parametrize(parser, path, *args, **kwargs):
cases = _file_parser(parser, path, *args, **kwargs)
return dict_parametrize(cases)
And then in the test file itself, it does:
@pytest.mark.asyncio
@file_parametrize(parser, FILE, sheet_name="Info Extraction")
async def test_info_extraction(a, b, c, expected):
The idea is that we give it an excel file and the parser
function converts each row into a test case. FILE
is defined as:
FILE = importlib.resources.files(tests) / "spec_files" / "info_extraction.xlsx"
After dealing with marking the info_extraction.xlsx
file as a resource to resolve file not found issues, it seems this test always passes instantly. If I run the test file with pytest, it takes a good 20 seconds to get through all the cases (there's external api calls). I've tried raising an exception from the test case and it still passes. Is there a way to gets pants to recognise these data driven tests?