Skip to content

Commit

Permalink
[UnitTests] Added TestCachedFixtureIsCopy
Browse files Browse the repository at this point in the history
Verifies that tvm.testing.fixture caching returns copy of object, not
the original object.
  • Loading branch information
Lunderberg committed Aug 10, 2021
1 parent d80080f commit f744b1f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/python/unittest/test_tvm_testing_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,22 @@ def test_cached_count(self):
assert self.cached_calls == len(self.param1_vals)


class TestCachedFixtureIsCopy:
param = tvm.testing.parameter(1, 2, 3, 4)

@tvm.testing.fixture(cache_return_value=True)
def cached_mutable_fixture(self):
return {"val": 0}

def test_modifies_fixture(self, param, cached_mutable_fixture):
assert cached_mutable_fixture["val"] == 0

# The tests should receive a copy of the fixture value. If
# the test receives the original and not a copy, then this
# will cause the next parametrization to fail.
cached_mutable_fixture["val"] = param


class TestBrokenFixture:
# Tests that use a fixture that throws an exception fail, and are
# marked as setup failures. The tests themselves are never run.
Expand Down

0 comments on commit f744b1f

Please sign in to comment.