From c0f6399267f8fa7ee3d0259f314636306409b09d Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Thu, 30 Mar 2023 11:53:09 -0700 Subject: [PATCH 1/3] [pytest] Don't return values from test_* functions Pytest expects test functions to return None, and errors to be flagged via exceptions. It actually emits warnings for "return" statements encountered in test_ functions. --- tests/python/contrib/test_hexagon/test_2d_physical_buffers.py | 2 +- tests/python/contrib/test_hexagon/test_maxpool2d_blocked.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/python/contrib/test_hexagon/test_2d_physical_buffers.py b/tests/python/contrib/test_hexagon/test_2d_physical_buffers.py index 4aa12aedf215..45fb8110f610 100644 --- a/tests/python/contrib/test_hexagon/test_2d_physical_buffers.py +++ b/tests/python/contrib/test_hexagon/test_2d_physical_buffers.py @@ -331,7 +331,7 @@ def test_cache_shape(self, ir_module, input_layout, working_layout, output_layou assert len(buffer.shape) == expected_physical_dimensions def test_lower(self, schedule_args): - return tvm.lower(*schedule_args) + tvm.lower(*schedule_args) @requires_hexagon_toolchain def test_build(self, schedule_args, target_host, input_layout, working_layout, output_layout): diff --git a/tests/python/contrib/test_hexagon/test_maxpool2d_blocked.py b/tests/python/contrib/test_hexagon/test_maxpool2d_blocked.py index dbf3f3d790f5..ad886d7a324f 100644 --- a/tests/python/contrib/test_hexagon/test_maxpool2d_blocked.py +++ b/tests/python/contrib/test_hexagon/test_maxpool2d_blocked.py @@ -151,7 +151,6 @@ def test_maxpool(self, shape_nhwc, window_size, stride, pad, dtype, target): padding=(pad, pad, pad, pad), dtype=dtype, ) - return output, ref_output if __name__ == "__main__": From 6e6f5d1602b17afdd3f1c9823342819c0bcf3634 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Mon, 3 Apr 2023 14:09:29 -0700 Subject: [PATCH 2/3] Add explicit asserts --- tests/python/contrib/test_hexagon/test_2d_physical_buffers.py | 2 +- tests/python/contrib/test_hexagon/test_maxpool2d_blocked.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/python/contrib/test_hexagon/test_2d_physical_buffers.py b/tests/python/contrib/test_hexagon/test_2d_physical_buffers.py index 45fb8110f610..d22b2db9c399 100644 --- a/tests/python/contrib/test_hexagon/test_2d_physical_buffers.py +++ b/tests/python/contrib/test_hexagon/test_2d_physical_buffers.py @@ -331,7 +331,7 @@ def test_cache_shape(self, ir_module, input_layout, working_layout, output_layou assert len(buffer.shape) == expected_physical_dimensions def test_lower(self, schedule_args): - tvm.lower(*schedule_args) + assert tvm.lower(*schedule_args) @requires_hexagon_toolchain def test_build(self, schedule_args, target_host, input_layout, working_layout, output_layout): diff --git a/tests/python/contrib/test_hexagon/test_maxpool2d_blocked.py b/tests/python/contrib/test_hexagon/test_maxpool2d_blocked.py index ad886d7a324f..f15041a6e616 100644 --- a/tests/python/contrib/test_hexagon/test_maxpool2d_blocked.py +++ b/tests/python/contrib/test_hexagon/test_maxpool2d_blocked.py @@ -151,6 +151,7 @@ def test_maxpool(self, shape_nhwc, window_size, stride, pad, dtype, target): padding=(pad, pad, pad, pad), dtype=dtype, ) + assert all([output, ref_output]) if __name__ == "__main__": From 3f5d2c793db91d9f1c162b4f057d09f279d152c8 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Tue, 4 Apr 2023 06:44:58 -0700 Subject: [PATCH 3/3] Use not-None in assertion --- tests/python/contrib/test_hexagon/test_maxpool2d_blocked.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/python/contrib/test_hexagon/test_maxpool2d_blocked.py b/tests/python/contrib/test_hexagon/test_maxpool2d_blocked.py index f15041a6e616..0cc6dbd8163f 100644 --- a/tests/python/contrib/test_hexagon/test_maxpool2d_blocked.py +++ b/tests/python/contrib/test_hexagon/test_maxpool2d_blocked.py @@ -151,7 +151,7 @@ def test_maxpool(self, shape_nhwc, window_size, stride, pad, dtype, target): padding=(pad, pad, pad, pad), dtype=dtype, ) - assert all([output, ref_output]) + assert all([output is not None, ref_output is not None]) if __name__ == "__main__":