Lunderberg commented on PR #11657: URL: https://github.com/apache/tvm/pull/11657#issuecomment-1159717291
@areusch We can, and that's basically what the `tvm.testing.parameter` function does internally ([link](https://github.com/apache/tvm/blob/main/python/tvm/testing/utils.py#L1305)). The main issue comes when pytest is finding the fixtures to be used, and avoiding the need to repeatedly define the fixture name. I had tracked it down to the [the function that locates fixtures](https://github.com/pytest-dev/pytest/blob/main/src/_pytest/fixtures.py#L1572) to convince myself that it needed to be a named object in the file. (I been hoping that there would be some pytest variable that could hold the fixture objects, rather than requiring a python variable.) * No parameter-specific support. Test writers would call `pytest.fixture` directly to define the parameter. This would pass the linting for `lower_case` function names, but gets to be rather clunky and copy-paste-y when defining several parameters. ```python @pytest.fixture(params=[1, 2, 3]) def my_parameter(request): return request.param ``` * Repeat the parameter name. This would allow the `ALL_CAPS` name for the python variable, while having the fixture be named in `lower_case`. I felt this would be confusing, since there would exist two names and it would be unclear which one should be used in the unit test. ```python MY_PARAMETER = tvm.testing.parameter(1, 2, 3, name='my_parameter') ``` * Insert a dummy variable in the callee's scope to define a variable at the scope. This would work and wouldn't introduce any lint issues, but would break if `tvm.testing.parameter` is ever called as a subroutine, since the callee's scope wouldn't be the appropriate place for the inserted variable. ```python tvm.testing.parameter(1, 2, 3, name='my_parameter') ``` * Use the python variable name as the fixture name. This is the behavior I settled on, because it minimizes boilerplace from the user, doesn't require separate variable/fixture names, and wouldn't use fragile `inspect.stack` hackery. ```python my_parameter = tvm.testing.parameter(1, 2, 3) ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
