You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2021/09/03 19:24:07 UTC
[GitHub] [tvm] comaniac commented on a change in pull request #8920: [Bugfix] Fix visit_attrs error if its function pointer is equal to nullptr
comaniac commented on a change in pull request #8920:
URL: https://github.com/apache/tvm/pull/8920#discussion_r702116775
##########
File path: tests/python/unittest/test_ir_container.py
##########
@@ -34,6 +34,21 @@ def test_array_save_load_json():
assert a_loaded[1].value == 2
+def test_dir_array():
+ a = tvm.runtime.convert([1, 2, 3])
+ 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
Review comment:
If you are expecting an exception, please use
```
with pytest.raise(AttributeError):
getattr(a, "test_key")
```
In this particular case, it might be even simpler :
```
assert not hasattr(a, "test_key")
```
##########
File path: tests/python/unittest/test_ir_container.py
##########
@@ -34,6 +34,21 @@ def test_array_save_load_json():
assert a_loaded[1].value == 2
+def test_dir_array():
+ a = tvm.runtime.convert([1, 2, 3])
+ dir(a)
Review comment:
It would be better to check its outputs instead of just letting it go. It could be at least `assert dir(a)`.
##########
File path: tests/python/unittest/test_ir_container.py
##########
@@ -91,5 +125,10 @@ def test_ndarray_container():
test_map()
test_array_save_load_json()
test_map_save_load_json()
+ test_dir_array()
+ test_dir_map()
+ test_getattr_array()
+ test_getattr_map()
Review comment:
Would you mind to help change to the pytest style?
```python
if __name__ == "__main__":
pytest.main([__file__])
```
--
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: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org