Open adamchainz opened 1 year ago
Hello @adamchainz I was able to reproduce the potential issue with request (now no potential)
@pytest.mark.parametrize("query_param", VALUES)
def test_request_factory_with_parametrize(query_param):
request = RequestFactory()
with record():
run_query("default", f"SELECT {query_param}")
Here the request is not the one expected in request = frame.f_locals.get("request", None)
I ran the test_auto_name_with_request
to check what request
is expected and found following:
>>> type(request)
<class '_pytest.fixtures.SubRequest'>
Hope it will help and looking for the fix!
Description
Problem noted in review of my old code: https://github.com/adamchainz/django-perf-rec/pull/537#discussion_r1209735218
Currently django-perf-rec finds the current test name by stack inspection, looking for the pytest request object. This is fragile and slow.
Instead, the pytest plugin could store the
request
object, from which all the requisite "current test" details can be found.