Skip to content

Commit

Permalink
change test_ir_container.py to the pytest style
Browse files Browse the repository at this point in the history
  • Loading branch information
syang-ng committed Sep 4, 2021
1 parent e29e65a commit 6d8cc1d
Showing 1 changed file with 9 additions and 26 deletions.
35 changes: 9 additions & 26 deletions tests/python/unittest/test_ir_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
import pytest
import tvm
from tvm import te
import numpy as np
Expand All @@ -36,17 +37,13 @@ def test_array_save_load_json():

def test_dir_array():
a = tvm.runtime.convert([1, 2, 3])
dir(a)
assert dir(a)


def test_getattr_array():
a = tvm.runtime.convert([1, 2, 3])
type_key = getattr(a, "type_key")
assert type_key == "Array"
try:
getattr(a, "test_key")
except AttributeError:
pass
assert getattr(a, "type_key") == "Array"
assert not hasattr(a, "test_key")


def test_map():
Expand Down Expand Up @@ -89,19 +86,15 @@ def test_dir_map():
a = te.var("a")
b = te.var("b")
amap = tvm.runtime.convert({a: 2, b: 3})
dir(amap)
assert dir(amap)


def test_getattr_map():
a = te.var("a")
b = te.var("b")
amap = tvm.runtime.convert({a: 2, b: 3})
type_key = getattr(amap, "type_key")
assert type_key == "Map"
try:
getattr(amap, "test_key")
except AttributeError:
pass
assert getattr(amap, "type_key") == "Map"
assert not hasattr(amap, "test_key")


def test_in_container():
Expand All @@ -120,15 +113,5 @@ def test_ndarray_container():


if __name__ == "__main__":
test_str_map()
test_array()
test_map()
test_array_save_load_json()
test_map_save_load_json()
test_dir_array()
test_dir_map()
test_getattr_array()
test_getattr_map()
test_in_container()
test_ndarray_container()

pytest.main([__file__])

0 comments on commit 6d8cc1d

Please sign in to comment.