With pytest 7.4.1, using tvm.testing.parameters no longer works. Example:
import pytest
import tvm
import tvm.testing
param_x, param_y = tvm.testing.parameters((1, 2))
def test(param_x, param_y):
return True
gives the following error:
request = <SubRequest 'param_x' for <Function test>>, _cls = ()
def fixture_func(*_cls, request):
> return request.param
E AttributeError: 'SubRequest' object has no attribute 'param'
I tried adding params=param_values, ids=ids
in the call to pytest.fixture in tvm/testing/utils.py. It fixed the unit test above, but caused hangs when running the TVM test suite.
Does anyone know how to fix this?
I solved this issue. In case anyone wonders, here’s what happened.
I was running python -m pytest test.py
from tests/python/contrib/test_hexagon. There is a conftest.py file in there that loaded a local plugin. What was happening is that pytest-7.2.2 loaded this conftest.py and all other conftest.py that were in the parent directories, whereas pytest-7.4.2 only loaded the local conftest.py.
The pytest fixtures defined via tvm.testing.parameters are implemented in tvm/testing/plugin.py, which is loaded from the conftest.py in the TVM root directory. If that plugin does not get loaded, you will the error that I did.
The solution is to run pytest from the TVM root directory, so that all conftest.py are loaded.