Skip to content

Commit ed4d58e

Browse files
committed
Some work on adding additional metadata to the json report
1 parent 3f25af0 commit ed4d58e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

conftest.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from pathlib import Path
33

44
from hypothesis import settings
5-
from pytest import mark
5+
from pytest import mark, fixture
66

77
from array_api_tests import _array_module as xp
88
from array_api_tests._array_module import _UndefinedStub
@@ -132,3 +132,16 @@ def pytest_metadata(metadata):
132132
Additional metadata for --json-report.
133133
"""
134134
metadata['array_api_tests_module'] = xp.mod_name
135+
136+
@fixture(autouse=True)
137+
def add_api_name_to_metadata(request, json_metadata):
138+
test_module = request.module.__name__
139+
test_function = request.function.__name__
140+
assert test_function.startswith('test_'), 'unexpected test function name'
141+
142+
if test_module == 'array_api_tests.test_has_names':
143+
array_api_function_name = None
144+
else:
145+
array_api_function_name = test_function[len('test_'):]
146+
147+
json_metadata['array_api_function_name'] = array_api_function_name

0 commit comments

Comments
 (0)