Skip to content

Commit 449fbf8

Browse files
committed
[UnitTests] More careful removal of fixture functions from module global scope.
- Initial implementation only checked hasattr(obj, "_pytestfixturefunction") before removing obj, which gave false positives for objects that implement __getattr__, such as caffe.layers. Now, also check that the value contained is a FixtureFunctionMarker.
1 parent 9b59706 commit 449fbf8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

python/tvm/testing.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def test_something():
6161
import sys
6262
import time
6363
import pytest
64+
import _pytest
6465
import numpy as np
6566
import tvm
6667
import tvm.arith
@@ -1184,7 +1185,9 @@ def _remove_global_fixture_definitions(items):
11841185
for module in modules:
11851186
for name in dir(module):
11861187
obj = getattr(module, name)
1187-
if hasattr(obj, "_pytestfixturefunction"):
1188+
if hasattr(obj, "_pytestfixturefunction") and isinstance(
1189+
obj._pytestfixturefunction, _pytest.fixtures.FixtureFunctionMarker
1190+
):
11881191
delattr(module, name)
11891192

11901193

0 commit comments

Comments
 (0)