Correct, the different cases are intended to show the entire contents of a test
file. The names in this example are chosen so that it can be run with minimal
interaction between cases.
For the `fixture(scope="module")`, this indicates when pytest should clean up a
fixture, but it is only available to be accessed by tests that explicitly
accept the fixture as a function argument. With the default scope of
`"function"`, the cleanup is done between each test. Absent any caching that
we add, this scope is what prevents the fixture from being regenerated,
repeating the expensive setup, with each target/size parameter.
For the caching, using the cached values should be no different than passing an
argument into a `verify_*` function, or a `verify_*` function accessing a
nonlocal variable. In either case, we're relying on the test not to make
modifications to the setup that is shared between multiple tests.
That said, if we decide to use fixtures as the method to handle expensive
setup, I think that we should add a helper function `tvm.testing.fixture` to
reduce the amount of boilerplate, avoid potential mistakes (e.g. having
`@lru_cache` before `@pytest.fixture` instead of after), and as a place to
disable the cache entirely based on an environment variable. I haven't
implemented it yet, but the behavior would be something like the following.
```
# Using pytest directly, defining parametrized fixture
@pytest.fixture(scope="module", params=[1, 10, 100])
def size(request):
return request.param
# With helper function, same behavior as above
tvm.testing.fixture(name="size", params=[1,10,100])
# Using pytest directly, defining a cached parameter derived from `size`
@pytest.fixture(scope="module")
@functools.lru_cache
def expensive_size_dependent(size):
...
# With helper function, same behavior as above,
# except that caching can be overridden with environment variable.
@tvm.testing.fixture(cache=True)
def expensive_size_dependent(size):
...
```
---
[Visit
Topic](https://discuss.tvm.apache.org/t/rfc-parametrized-unit-tests/9946/9) to
respond.
You are receiving this because you enabled mailing list mode.
To unsubscribe from these emails, [click
here](https://discuss.tvm.apache.org/email/unsubscribe/b5a3a077ef1325d8f5ba6f44ab839f7ca1110666c71d1c01fc1a7a4055bbf550).