You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by ju...@apache.org on 2023/01/07 05:54:12 UTC

[tvm] branch main updated: [Tests] Replace pytest.main with tvm.testing.main (#13717)

This is an automated email from the ASF dual-hosted git repository.

junrushao pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
     new bd37515cfb [Tests] Replace pytest.main with tvm.testing.main (#13717)
bd37515cfb is described below

commit bd37515cfb1ce6a56f03b9ccda94ec9ae3f8cca9
Author: Christopher Sidebottom <ch...@arm.com>
AuthorDate: Sat Jan 7 05:54:07 2023 +0000

    [Tests] Replace pytest.main with tvm.testing.main (#13717)
    
    This ensures that if you want to run a specific test script then at least it's reasonably consistent and as people copy test files they'll use the new function :smile_cat:
---
 tests/micro/stm32/test_code_emitter.py                               | 2 +-
 tests/python/contrib/test_cublas.py                                  | 2 +-
 .../test_ethosu/cascader/test_ethosu_binary_elementwise_matcher.py   | 2 +-
 .../python/contrib/test_ethosu/cascader/test_ethosu_block_config.py  | 2 +-
 .../contrib/test_ethosu/cascader/test_ethosu_conv2d_matcher.py       | 2 +-
 .../contrib/test_ethosu/cascader/test_ethosu_depthwise2d_matcher.py  | 2 +-
 .../contrib/test_ethosu/cascader/test_ethosu_identity_matcher.py     | 2 +-
 .../contrib/test_ethosu/cascader/test_ethosu_inline_matcher.py       | 2 +-
 tests/python/contrib/test_ethosu/cascader/test_ethosu_part.py        | 2 +-
 .../contrib/test_ethosu/cascader/test_ethosu_part_performance.py     | 2 +-
 .../contrib/test_ethosu/cascader/test_ethosu_pooling_matcher.py      | 2 +-
 .../test_ethosu/cascader/test_ethosu_unary_elementwise_matcher.py    | 2 +-
 tests/python/contrib/test_ethosu/cascader/test_graph.py              | 2 +-
 tests/python/contrib/test_ethosu/cascader/test_pareto.py             | 2 +-
 tests/python/contrib/test_ethosu/cascader/test_plan.py               | 2 +-
 tests/python/contrib/test_ethosu/cascader/test_plan_generator.py     | 2 +-
 tests/python/contrib/test_ethosu/cascader/test_propagator.py         | 2 +-
 tests/python/contrib/test_ethosu/cascader/test_proposal_generator.py | 2 +-
 tests/python/contrib/test_ethosu/cascader/test_scheduler.py          | 2 +-
 tests/python/contrib/test_ethosu/cascader/test_stripe_config.py      | 2 +-
 tests/python/contrib/test_ethosu/cascader/test_tensor_config.py      | 2 +-
 tests/python/contrib/test_ethosu/test_attr_passing.py                | 2 +-
 tests/python/contrib/test_ethosu/test_codegen.py                     | 5 +----
 tests/python/contrib/test_ethosu/test_compiler.py                    | 2 +-
 tests/python/contrib/test_ethosu/test_copy_compute_reordering.py     | 2 +-
 tests/python/contrib/test_ethosu/test_create_tiles.py                | 2 +-
 tests/python/contrib/test_ethosu/test_encode_constants.py            | 2 +-
 tests/python/contrib/test_ethosu/test_extract_constants.py           | 2 +-
 tests/python/contrib/test_ethosu/test_layout_optimizer.py            | 2 +-
 tests/python/contrib/test_ethosu/test_legalize.py                    | 2 +-
 tests/python/contrib/test_ethosu/test_lookup_table.py                | 2 +-
 tests/python/contrib/test_ethosu/test_lower_to_te.py                 | 2 +-
 tests/python/contrib/test_ethosu/test_networks.py                    | 2 +-
 tests/python/contrib/test_ethosu/test_preprocess.py                  | 2 +-
 tests/python/contrib/test_ethosu/test_remove_concatenates.py         | 2 +-
 tests/python/contrib/test_ethosu/test_replace_binary_elementwise.py  | 2 +-
 tests/python/contrib/test_ethosu/test_replace_conv2d.py              | 2 +-
 tests/python/contrib/test_ethosu/test_replace_copy.py                | 2 +-
 tests/python/contrib/test_ethosu/test_replace_identity.py            | 2 +-
 tests/python/contrib/test_ethosu/test_replace_pooling.py             | 2 +-
 tests/python/contrib/test_ethosu/test_replace_unary_elementwise.py   | 2 +-
 tests/python/contrib/test_ethosu/test_rolling_buffer.py              | 2 +-
 tests/python/contrib/test_ethosu/test_scheduler.py                   | 2 +-
 tests/python/contrib/test_ethosu/test_tir_to_cs_translator.py        | 2 +-
 tests/python/contrib/test_ethosu/test_type_inference.py              | 2 +-
 tests/python/contrib/test_ethosu/test_vela_api.py                    | 2 +-
 tests/python/contrib/test_libtorch_ops.py                            | 2 +-
 tests/python/contrib/test_nnpack.py                                  | 2 +-
 tests/python/contrib/test_vitis_ai/test_vitis_ai_codegen.py          | 2 +-
 tests/python/contrib/test_vitis_ai/test_vitis_ai_runtime_cpu_part.py | 2 +-
 tests/python/driver/tvmc/test_pass_list.py                           | 2 +-
 tests/python/frontend/mxnet/test_forward.py                          | 2 +-
 tests/python/frontend/paddlepaddle/test_forward.py                   | 2 +-
 tests/python/frontend/tensorflow/test_forward.py                     | 2 +-
 tests/python/frontend/tensorflow2/test_functional_models.py          | 2 +-
 tests/python/frontend/tensorflow2/test_sequential_models.py          | 2 +-
 tests/python/integration/test_reduce.py                              | 3 +--
 tests/python/integration/test_winograd_nnpack.py                     | 4 +---
 tests/python/relay/test_adt.py                                       | 2 +-
 tests/python/relay/test_analysis_basic_block_normal_form.py          | 2 +-
 tests/python/relay/test_analysis_extract_intermediate_expr.py        | 2 +-
 tests/python/relay/test_analysis_extract_operators.py                | 2 +-
 tests/python/relay/test_auto_scheduler_task_extraction.py            | 2 +-
 tests/python/relay/test_backend_graph_executor.py                    | 2 +-
 tests/python/relay/test_backend_interpreter.py                       | 2 +-
 tests/python/relay/test_call_graph.py                                | 2 +-
 tests/python/relay/test_name_mangling.py                             | 2 +-
 tests/python/relay/test_op_grad_level2.py                            | 2 +-
 tests/python/relay/test_op_grad_level3.py                            | 2 +-
 tests/python/relay/test_op_grad_level4.py                            | 2 +-
 tests/python/relay/test_op_level1.py                                 | 2 +-
 tests/python/relay/test_op_level6.py                                 | 2 +-
 tests/python/relay/test_pass_alter_op_layout.py                      | 2 +-
 tests/python/relay/test_pass_convert_op_layout.py                    | 2 +-
 tests/python/relay/test_pass_defunctionalization.py                  | 2 +-
 tests/python/relay/test_pass_defuse_ops.py                           | 2 +-
 tests/python/relay/test_pass_dynamic_to_static.py                    | 2 +-
 tests/python/relay/test_pass_flexible_shape_dispatch.py              | 2 +-
 tests/python/relay/test_pass_fuse_ops.py                             | 2 +-
 tests/python/relay/test_pass_gradient.py                             | 2 +-
 tests/python/relay/test_pass_inline.py                               | 2 +-
 tests/python/relay/test_pass_lambda_lift.py                          | 2 +-
 tests/python/relay/test_pass_manager.py                              | 2 +-
 tests/python/relay/test_pass_merge_composite.py                      | 2 +-
 tests/python/relay/test_pass_remove_unused_functions.py              | 2 +-
 tests/python/relay/test_pass_simplify_expr.py                        | 2 +-
 tests/python/relay/test_pass_to_basic_block_normal_form.py           | 2 +-
 tests/python/relay/test_pass_unmatched_cases.py                      | 2 +-
 tests/python/relay/test_pipeline_executor.py                         | 2 +-
 tests/python/relay/test_tensor_array.py                              | 2 +-
 tests/python/relay/test_to_mixed_precision.py                        | 2 +-
 tests/python/relay/test_type_infer.py                                | 4 +---
 tests/python/relay/test_vm_serialization.py                          | 2 +-
 tests/python/unittest/test_aot_legalize_packed_call.py               | 2 +-
 tests/python/unittest/test_arith_deduce_bound.py                     | 2 +-
 tests/python/unittest/test_arith_rewrite_simplify.py                 | 2 +-
 tests/python/unittest/test_arith_solve_linear_equations.py           | 2 +-
 tests/python/unittest/test_arith_solve_linear_inequality.py          | 2 +-
 tests/python/unittest/test_ir_container.py                           | 2 +-
 tests/python/unittest/test_micro_model_library_format.py             | 2 +-
 tests/python/unittest/test_target_codegen_cuda.py                    | 2 +-
 tests/python/unittest/test_tir_analysis_stmt_finding.py              | 2 +-
 tests/python/unittest/test_tir_buffer.py                             | 2 +-
 tests/python/unittest/test_tir_nodes.py                              | 2 +-
 tests/python/unittest/test_tir_te_extern_primfunc.py                 | 2 +-
 tests/python/unittest/test_tir_transform_convert_for_loops_serial.py | 2 +-
 tests/python/unittest/test_tir_transform_hoist_if.py                 | 2 +-
 tests/python/unittest/test_tir_transform_inject_rolling_buffer.py    | 2 +-
 tests/python/unittest/test_tir_transform_ir_utils.py                 | 2 +-
 tests/python/unittest/test_tir_transform_lower_warp_memory.py        | 2 +-
 tests/python/unittest/test_tir_transform_make_unpacked_api.py        | 2 +-
 tests/python/unittest/test_tir_usmp_analysis_extract_bufferinfo.py   | 2 +-
 .../test_tir_usmp_transform_convert_pool_allocations_to_offsets.py   | 2 +-
 tests/python/unittest/test_tir_usmp_utils.py                         | 2 +-
 tests/python/unittest/test_type_annotation_checker.py                | 3 ++-
 115 files changed, 116 insertions(+), 123 deletions(-)

diff --git a/tests/micro/stm32/test_code_emitter.py b/tests/micro/stm32/test_code_emitter.py
index 01bfaefc18..0d1290acfc 100644
--- a/tests/micro/stm32/test_code_emitter.py
+++ b/tests/micro/stm32/test_code_emitter.py
@@ -392,4 +392,4 @@ def test_mnist():
 
 
 if __name__ == "__main__":
-    sys.exit(pytest.main([os.path.dirname(__file__)] + sys.argv[1:]))
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_cublas.py b/tests/python/contrib/test_cublas.py
index 0ae1e8e9ad..f3e3aa74af 100644
--- a/tests/python/contrib/test_cublas.py
+++ b/tests/python/contrib/test_cublas.py
@@ -378,4 +378,4 @@ def test_relay_cublas_dense(n, m, k, in_dtype, out_dtype):
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/cascader/test_ethosu_binary_elementwise_matcher.py b/tests/python/contrib/test_ethosu/cascader/test_ethosu_binary_elementwise_matcher.py
index 062e5ba0fa..ffc24ca006 100644
--- a/tests/python/contrib/test_ethosu/cascader/test_ethosu_binary_elementwise_matcher.py
+++ b/tests/python/contrib/test_ethosu/cascader/test_ethosu_binary_elementwise_matcher.py
@@ -175,4 +175,4 @@ def test_ethosu_binary_elementwise_matcher(
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/cascader/test_ethosu_block_config.py b/tests/python/contrib/test_ethosu/cascader/test_ethosu_block_config.py
index 66d9b4647c..8b372e45c3 100644
--- a/tests/python/contrib/test_ethosu/cascader/test_ethosu_block_config.py
+++ b/tests/python/contrib/test_ethosu/cascader/test_ethosu_block_config.py
@@ -457,4 +457,4 @@ def test_force_block_config_elementwise(ofm_layout, block_config_str, expected_b
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/cascader/test_ethosu_conv2d_matcher.py b/tests/python/contrib/test_ethosu/cascader/test_ethosu_conv2d_matcher.py
index 76adb0b4cb..f9f2312ba7 100644
--- a/tests/python/contrib/test_ethosu/cascader/test_ethosu_conv2d_matcher.py
+++ b/tests/python/contrib/test_ethosu/cascader/test_ethosu_conv2d_matcher.py
@@ -179,4 +179,4 @@ def test_ethosu_conv2d_block_config_from_matcher(
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/cascader/test_ethosu_depthwise2d_matcher.py b/tests/python/contrib/test_ethosu/cascader/test_ethosu_depthwise2d_matcher.py
index 1e6b6d58b2..8625a48444 100644
--- a/tests/python/contrib/test_ethosu/cascader/test_ethosu_depthwise2d_matcher.py
+++ b/tests/python/contrib/test_ethosu/cascader/test_ethosu_depthwise2d_matcher.py
@@ -100,4 +100,4 @@ def test_ethosu_depthwise2d_matcher(kernel, stride, dilation, padding, ifm_layou
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/cascader/test_ethosu_identity_matcher.py b/tests/python/contrib/test_ethosu/cascader/test_ethosu_identity_matcher.py
index 4609a5bc37..4bdccfced3 100644
--- a/tests/python/contrib/test_ethosu/cascader/test_ethosu_identity_matcher.py
+++ b/tests/python/contrib/test_ethosu/cascader/test_ethosu_identity_matcher.py
@@ -55,4 +55,4 @@ def test_ethosu_identity_matcher():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/cascader/test_ethosu_inline_matcher.py b/tests/python/contrib/test_ethosu/cascader/test_ethosu_inline_matcher.py
index 1eebbe40c1..ff5530d433 100644
--- a/tests/python/contrib/test_ethosu/cascader/test_ethosu_inline_matcher.py
+++ b/tests/python/contrib/test_ethosu/cascader/test_ethosu_inline_matcher.py
@@ -47,4 +47,4 @@ def test_ethosu_inline_matcher():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/cascader/test_ethosu_part.py b/tests/python/contrib/test_ethosu/cascader/test_ethosu_part.py
index 105b6722e8..22196e237e 100644
--- a/tests/python/contrib/test_ethosu/cascader/test_ethosu_part.py
+++ b/tests/python/contrib/test_ethosu/cascader/test_ethosu_part.py
@@ -57,4 +57,4 @@ def test_ethosu_part():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/cascader/test_ethosu_part_performance.py b/tests/python/contrib/test_ethosu/cascader/test_ethosu_part_performance.py
index 437b0a9ead..f68e295597 100644
--- a/tests/python/contrib/test_ethosu/cascader/test_ethosu_part_performance.py
+++ b/tests/python/contrib/test_ethosu/cascader/test_ethosu_part_performance.py
@@ -231,4 +231,4 @@ def test_conv_performance(
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/cascader/test_ethosu_pooling_matcher.py b/tests/python/contrib/test_ethosu/cascader/test_ethosu_pooling_matcher.py
index b998ddaf70..38aeee05f9 100644
--- a/tests/python/contrib/test_ethosu/cascader/test_ethosu_pooling_matcher.py
+++ b/tests/python/contrib/test_ethosu/cascader/test_ethosu_pooling_matcher.py
@@ -79,4 +79,4 @@ def test_ethosu_pooling_matcher(pool_shape, stride, padding, ifm_layout, ofm_lay
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/cascader/test_ethosu_unary_elementwise_matcher.py b/tests/python/contrib/test_ethosu/cascader/test_ethosu_unary_elementwise_matcher.py
index 8139f1518f..e79c75c00c 100644
--- a/tests/python/contrib/test_ethosu/cascader/test_ethosu_unary_elementwise_matcher.py
+++ b/tests/python/contrib/test_ethosu/cascader/test_ethosu_unary_elementwise_matcher.py
@@ -131,4 +131,4 @@ def test_ethosu_unary_elementwise_matcher(ofm_shape, ifm_layout, ofm_layout, op_
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/cascader/test_graph.py b/tests/python/contrib/test_ethosu/cascader/test_graph.py
index 616800f69d..c3d5c0fd00 100644
--- a/tests/python/contrib/test_ethosu/cascader/test_graph.py
+++ b/tests/python/contrib/test_ethosu/cascader/test_graph.py
@@ -201,4 +201,4 @@ def test_create_diamond_graph(MobileNetv2DiamondTE):
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/cascader/test_pareto.py b/tests/python/contrib/test_ethosu/cascader/test_pareto.py
index baf8739c08..65d3619c64 100644
--- a/tests/python/contrib/test_ethosu/cascader/test_pareto.py
+++ b/tests/python/contrib/test_ethosu/cascader/test_pareto.py
@@ -146,4 +146,4 @@ def test_pareto_cull_plans(num_plans, max_plans, SRAM):
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/cascader/test_plan.py b/tests/python/contrib/test_ethosu/cascader/test_plan.py
index ddc40b49ac..0d33743cd9 100644
--- a/tests/python/contrib/test_ethosu/cascader/test_plan.py
+++ b/tests/python/contrib/test_ethosu/cascader/test_plan.py
@@ -241,4 +241,4 @@ def test_plan_merge(DRAM, SRAM):
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/cascader/test_plan_generator.py b/tests/python/contrib/test_ethosu/cascader/test_plan_generator.py
index c35ad15e23..c0d2a2f0c9 100644
--- a/tests/python/contrib/test_ethosu/cascader/test_plan_generator.py
+++ b/tests/python/contrib/test_ethosu/cascader/test_plan_generator.py
@@ -302,4 +302,4 @@ if ethosu_enabled:
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/cascader/test_propagator.py b/tests/python/contrib/test_ethosu/cascader/test_propagator.py
index 2a6f442f12..9712d00e52 100644
--- a/tests/python/contrib/test_ethosu/cascader/test_propagator.py
+++ b/tests/python/contrib/test_ethosu/cascader/test_propagator.py
@@ -133,4 +133,4 @@ def test_propagate(propagator, input_stripe_config, output_stripe_config):
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/cascader/test_proposal_generator.py b/tests/python/contrib/test_ethosu/cascader/test_proposal_generator.py
index b1cba8dfd9..8a573c05fa 100644
--- a/tests/python/contrib/test_ethosu/cascader/test_proposal_generator.py
+++ b/tests/python/contrib/test_ethosu/cascader/test_proposal_generator.py
@@ -157,4 +157,4 @@ if ethosu_enabled:
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/cascader/test_scheduler.py b/tests/python/contrib/test_ethosu/cascader/test_scheduler.py
index 2dce6dfdd6..417aeb9ed6 100644
--- a/tests/python/contrib/test_ethosu/cascader/test_scheduler.py
+++ b/tests/python/contrib/test_ethosu/cascader/test_scheduler.py
@@ -80,4 +80,4 @@ def test_compute_cycles_annotation(SRAM, FLASH, TwoConv2DTE):
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/cascader/test_stripe_config.py b/tests/python/contrib/test_ethosu/cascader/test_stripe_config.py
index 2ca1838b7f..f0142167e7 100644
--- a/tests/python/contrib/test_ethosu/cascader/test_stripe_config.py
+++ b/tests/python/contrib/test_ethosu/cascader/test_stripe_config.py
@@ -212,4 +212,4 @@ def test_count_stripes_sliding_window(stripe_config, expected_stripe_counts):
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/cascader/test_tensor_config.py b/tests/python/contrib/test_ethosu/cascader/test_tensor_config.py
index 68290e667e..eaab420fbf 100644
--- a/tests/python/contrib/test_ethosu/cascader/test_tensor_config.py
+++ b/tests/python/contrib/test_ethosu/cascader/test_tensor_config.py
@@ -107,4 +107,4 @@ def test_get_recompute_buffer(DRAM):
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/test_attr_passing.py b/tests/python/contrib/test_ethosu/test_attr_passing.py
index bb8b4491ee..a770a2668a 100644
--- a/tests/python/contrib/test_ethosu/test_attr_passing.py
+++ b/tests/python/contrib/test_ethosu/test_attr_passing.py
@@ -45,4 +45,4 @@ def test_compiler_attr_default():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/test_codegen.py b/tests/python/contrib/test_ethosu/test_codegen.py
index 89c87325ba..e06e36638d 100644
--- a/tests/python/contrib/test_ethosu/test_codegen.py
+++ b/tests/python/contrib/test_ethosu/test_codegen.py
@@ -1144,7 +1144,4 @@ def test_tflite_fully_connected(
 
 
 if __name__ == "__main__":
-    import sys
-    import pytest
-
-    sys.exit(pytest.main([__file__] + sys.argv[1:]))
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/test_compiler.py b/tests/python/contrib/test_ethosu/test_compiler.py
index 5da91632bd..3bf7abb8f1 100644
--- a/tests/python/contrib/test_ethosu/test_compiler.py
+++ b/tests/python/contrib/test_ethosu/test_compiler.py
@@ -63,4 +63,4 @@ def test_lower_to_tir_arg_count(relay_function, arg_count):
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/test_copy_compute_reordering.py b/tests/python/contrib/test_ethosu/test_copy_compute_reordering.py
index 8c598fe0d7..586b8b380e 100644
--- a/tests/python/contrib/test_ethosu/test_copy_compute_reordering.py
+++ b/tests/python/contrib/test_ethosu/test_copy_compute_reordering.py
@@ -679,4 +679,4 @@ def test_reordering_based_on_cycles_luts_present():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/test_create_tiles.py b/tests/python/contrib/test_ethosu/test_create_tiles.py
index 77b69df911..d51c438cbf 100644
--- a/tests/python/contrib/test_ethosu/test_create_tiles.py
+++ b/tests/python/contrib/test_ethosu/test_create_tiles.py
@@ -167,4 +167,4 @@ def test_create_tiles_multiple_var_occurrences():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/test_encode_constants.py b/tests/python/contrib/test_ethosu/test_encode_constants.py
index 61128da71c..a70e091b2c 100644
--- a/tests/python/contrib/test_ethosu/test_encode_constants.py
+++ b/tests/python/contrib/test_ethosu/test_encode_constants.py
@@ -529,4 +529,4 @@ def test_constant_as_input():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/test_extract_constants.py b/tests/python/contrib/test_ethosu/test_extract_constants.py
index 98094d8a4e..c5646b2c12 100644
--- a/tests/python/contrib/test_ethosu/test_extract_constants.py
+++ b/tests/python/contrib/test_ethosu/test_extract_constants.py
@@ -96,4 +96,4 @@ def test_extract_constants_multi():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/test_layout_optimizer.py b/tests/python/contrib/test_ethosu/test_layout_optimizer.py
index 4e134c9f4d..9cc3637fdf 100644
--- a/tests/python/contrib/test_ethosu/test_layout_optimizer.py
+++ b/tests/python/contrib/test_ethosu/test_layout_optimizer.py
@@ -737,4 +737,4 @@ def test_layout_optimizer_runs_in_compilation_pipeline():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__] + sys.argv[1:])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/test_legalize.py b/tests/python/contrib/test_ethosu/test_legalize.py
index 0f8fa4d84b..9b4dd467ff 100644
--- a/tests/python/contrib/test_ethosu/test_legalize.py
+++ b/tests/python/contrib/test_ethosu/test_legalize.py
@@ -2807,4 +2807,4 @@ def test_tflite_hard_swish(ifm_shape):
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/test_lookup_table.py b/tests/python/contrib/test_ethosu/test_lookup_table.py
index 8e044b5b99..e2b22897a0 100644
--- a/tests/python/contrib/test_ethosu/test_lookup_table.py
+++ b/tests/python/contrib/test_ethosu/test_lookup_table.py
@@ -172,4 +172,4 @@ def test_random_lut(accel_type):
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/test_lower_to_te.py b/tests/python/contrib/test_ethosu/test_lower_to_te.py
index c6b4ae05d3..9ec59af441 100644
--- a/tests/python/contrib/test_ethosu/test_lower_to_te.py
+++ b/tests/python/contrib/test_ethosu/test_lower_to_te.py
@@ -60,4 +60,4 @@ def test_ethosu_conv2d():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/test_networks.py b/tests/python/contrib/test_ethosu/test_networks.py
index 2b4ffd96ca..0df73d6dc5 100644
--- a/tests/python/contrib/test_ethosu/test_networks.py
+++ b/tests/python/contrib/test_ethosu/test_networks.py
@@ -199,4 +199,4 @@ def test_networks_with_usmp_and_cascader_with_striping(accel_type, model_url, wo
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/test_preprocess.py b/tests/python/contrib/test_ethosu/test_preprocess.py
index 41831f270d..0a0aa2cf69 100644
--- a/tests/python/contrib/test_ethosu/test_preprocess.py
+++ b/tests/python/contrib/test_ethosu/test_preprocess.py
@@ -340,4 +340,4 @@ def test_4ins_2outs():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/test_remove_concatenates.py b/tests/python/contrib/test_ethosu/test_remove_concatenates.py
index 379a35b1b4..4b4ba52b86 100644
--- a/tests/python/contrib/test_ethosu/test_remove_concatenates.py
+++ b/tests/python/contrib/test_ethosu/test_remove_concatenates.py
@@ -81,4 +81,4 @@ def test_concat():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/test_replace_binary_elementwise.py b/tests/python/contrib/test_ethosu/test_replace_binary_elementwise.py
index 330d5f7aa9..c1f82fbb7a 100644
--- a/tests/python/contrib/test_ethosu/test_replace_binary_elementwise.py
+++ b/tests/python/contrib/test_ethosu/test_replace_binary_elementwise.py
@@ -341,4 +341,4 @@ def test_shift_binary_elementwise_single(
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/test_replace_conv2d.py b/tests/python/contrib/test_ethosu/test_replace_conv2d.py
index 46c6976567..649f2a611d 100644
--- a/tests/python/contrib/test_ethosu/test_replace_conv2d.py
+++ b/tests/python/contrib/test_ethosu/test_replace_conv2d.py
@@ -818,4 +818,4 @@ def test_conv2d_big_pad():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/test_replace_copy.py b/tests/python/contrib/test_ethosu/test_replace_copy.py
index 7da3d7e5be..07124c62ae 100644
--- a/tests/python/contrib/test_ethosu/test_replace_copy.py
+++ b/tests/python/contrib/test_ethosu/test_replace_copy.py
@@ -132,4 +132,4 @@ def test_weight_stream():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/test_replace_identity.py b/tests/python/contrib/test_ethosu/test_replace_identity.py
index 2155d33f43..775ef12606 100644
--- a/tests/python/contrib/test_ethosu/test_replace_identity.py
+++ b/tests/python/contrib/test_ethosu/test_replace_identity.py
@@ -113,4 +113,4 @@ def test_identity(ifm_shape):
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/test_replace_pooling.py b/tests/python/contrib/test_ethosu/test_replace_pooling.py
index 8e8ed3f351..5647016378 100644
--- a/tests/python/contrib/test_ethosu/test_replace_pooling.py
+++ b/tests/python/contrib/test_ethosu/test_replace_pooling.py
@@ -278,4 +278,4 @@ def test_correct_stride_with_multiple_pooling():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/test_replace_unary_elementwise.py b/tests/python/contrib/test_ethosu/test_replace_unary_elementwise.py
index e48016180b..f61ace0d51 100644
--- a/tests/python/contrib/test_ethosu/test_replace_unary_elementwise.py
+++ b/tests/python/contrib/test_ethosu/test_replace_unary_elementwise.py
@@ -154,4 +154,4 @@ def test_unary_elementwise_single(
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/test_rolling_buffer.py b/tests/python/contrib/test_ethosu/test_rolling_buffer.py
index 8d348823d7..58376d8b61 100644
--- a/tests/python/contrib/test_ethosu/test_rolling_buffer.py
+++ b/tests/python/contrib/test_ethosu/test_rolling_buffer.py
@@ -100,4 +100,4 @@ def test_rolling_buffer_3_layers(axis, ifm_shape, pool_shape):
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/test_scheduler.py b/tests/python/contrib/test_ethosu/test_scheduler.py
index 695aed0d19..1e9b43b47a 100644
--- a/tests/python/contrib/test_ethosu/test_scheduler.py
+++ b/tests/python/contrib/test_ethosu/test_scheduler.py
@@ -234,4 +234,4 @@ def test_copy_constants_fully_connected_weights():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/test_tir_to_cs_translator.py b/tests/python/contrib/test_ethosu/test_tir_to_cs_translator.py
index f8a84aa083..f205bc3b26 100644
--- a/tests/python/contrib/test_ethosu/test_tir_to_cs_translator.py
+++ b/tests/python/contrib/test_ethosu/test_tir_to_cs_translator.py
@@ -1499,4 +1499,4 @@ def test_translate_ethosu_binary_elementwise_broadcasting(operator_type):
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/test_type_inference.py b/tests/python/contrib/test_ethosu/test_type_inference.py
index 1f304c117f..380d7532f8 100644
--- a/tests/python/contrib/test_ethosu/test_type_inference.py
+++ b/tests/python/contrib/test_ethosu/test_type_inference.py
@@ -475,4 +475,4 @@ def test_ethosu_unary_elementwise_invalid_dtype():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_ethosu/test_vela_api.py b/tests/python/contrib/test_ethosu/test_vela_api.py
index 75ca22d082..9f95e4b709 100644
--- a/tests/python/contrib/test_ethosu/test_vela_api.py
+++ b/tests/python/contrib/test_ethosu/test_vela_api.py
@@ -560,4 +560,4 @@ def test_encode_weights(accel):
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_libtorch_ops.py b/tests/python/contrib/test_libtorch_ops.py
index 2bfb78b407..153232a2f5 100644
--- a/tests/python/contrib/test_libtorch_ops.py
+++ b/tests/python/contrib/test_libtorch_ops.py
@@ -90,4 +90,4 @@ def test_backend():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_nnpack.py b/tests/python/contrib/test_nnpack.py
index c693af7e41..881226725a 100644
--- a/tests/python/contrib/test_nnpack.py
+++ b/tests/python/contrib/test_nnpack.py
@@ -217,4 +217,4 @@ def test_convolution_inference_without_weight_transform():
 
 
 if __name__ == "__main__":
-    pytest.main()
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_vitis_ai/test_vitis_ai_codegen.py b/tests/python/contrib/test_vitis_ai/test_vitis_ai_codegen.py
index e9195db88c..058faa8a24 100644
--- a/tests/python/contrib/test_vitis_ai/test_vitis_ai_codegen.py
+++ b/tests/python/contrib/test_vitis_ai/test_vitis_ai_codegen.py
@@ -380,4 +380,4 @@ if __name__ == "__main__":
     if sys.platform == "win32":
         print("Skip test on Windows for now")
         sys.exit(0)
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/contrib/test_vitis_ai/test_vitis_ai_runtime_cpu_part.py b/tests/python/contrib/test_vitis_ai/test_vitis_ai_runtime_cpu_part.py
index 0a2c13c5af..4273f5fa34 100644
--- a/tests/python/contrib/test_vitis_ai/test_vitis_ai_runtime_cpu_part.py
+++ b/tests/python/contrib/test_vitis_ai/test_vitis_ai_runtime_cpu_part.py
@@ -84,4 +84,4 @@ if __name__ == "__main__":
     if sys.platform == "win32":
         print("Skip test on Windows for now")
         sys.exit(0)
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/driver/tvmc/test_pass_list.py b/tests/python/driver/tvmc/test_pass_list.py
index f43da6371b..5b6c671015 100644
--- a/tests/python/driver/tvmc/test_pass_list.py
+++ b/tests/python/driver/tvmc/test_pass_list.py
@@ -33,4 +33,4 @@ def test_parse_pass_list_str():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/frontend/mxnet/test_forward.py b/tests/python/frontend/mxnet/test_forward.py
index 0e34719ea2..880416c7be 100644
--- a/tests/python/frontend/mxnet/test_forward.py
+++ b/tests/python/frontend/mxnet/test_forward.py
@@ -2363,4 +2363,4 @@ def test_forward_split_v2(
 
 
 if __name__ == "__main__":
-    pytest.main(["test_forward.py"])
+    tvm.testing.main()
diff --git a/tests/python/frontend/paddlepaddle/test_forward.py b/tests/python/frontend/paddlepaddle/test_forward.py
index ba983eb087..c0e54657a9 100644
--- a/tests/python/frontend/paddlepaddle/test_forward.py
+++ b/tests/python/frontend/paddlepaddle/test_forward.py
@@ -1682,4 +1682,4 @@ def test_forward_rnn():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/frontend/tensorflow/test_forward.py b/tests/python/frontend/tensorflow/test_forward.py
index f3195f05d4..dce18ee231 100755
--- a/tests/python/frontend/tensorflow/test_forward.py
+++ b/tests/python/frontend/tensorflow/test_forward.py
@@ -5835,4 +5835,4 @@ def test_forward_dense_bincount():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/frontend/tensorflow2/test_functional_models.py b/tests/python/frontend/tensorflow2/test_functional_models.py
index 42ad5b29af..53ece82217 100644
--- a/tests/python/frontend/tensorflow2/test_functional_models.py
+++ b/tests/python/frontend/tensorflow2/test_functional_models.py
@@ -646,4 +646,4 @@ def test_bincount_2d():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/frontend/tensorflow2/test_sequential_models.py b/tests/python/frontend/tensorflow2/test_sequential_models.py
index 1b5a6342f0..2ad4150863 100644
--- a/tests/python/frontend/tensorflow2/test_sequential_models.py
+++ b/tests/python/frontend/tensorflow2/test_sequential_models.py
@@ -165,4 +165,4 @@ def test_tensorlist_read_model():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/integration/test_reduce.py b/tests/python/integration/test_reduce.py
index eaac8ed266..283eab3eea 100644
--- a/tests/python/integration/test_reduce.py
+++ b/tests/python/integration/test_reduce.py
@@ -15,7 +15,6 @@
 # specific language governing permissions and limitations
 # under the License.
 """Test scheduling of reduction operations."""
-import pytest
 import numpy as np
 
 import tvm
@@ -675,4 +674,4 @@ def test_reduce_storage_reuse():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/integration/test_winograd_nnpack.py b/tests/python/integration/test_winograd_nnpack.py
index 9d9f4e10e6..d53dc21d63 100644
--- a/tests/python/integration/test_winograd_nnpack.py
+++ b/tests/python/integration/test_winograd_nnpack.py
@@ -183,6 +183,4 @@ def test_conv2d_nchw():
 
 
 if __name__ == "__main__":
-    import pytest
-
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/relay/test_adt.py b/tests/python/relay/test_adt.py
index 8cf31f9437..655ab11ee0 100644
--- a/tests/python/relay/test_adt.py
+++ b/tests/python/relay/test_adt.py
@@ -821,4 +821,4 @@ def test_iterate():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/relay/test_analysis_basic_block_normal_form.py b/tests/python/relay/test_analysis_basic_block_normal_form.py
index 5395be35ad..558f55ef40 100644
--- a/tests/python/relay/test_analysis_basic_block_normal_form.py
+++ b/tests/python/relay/test_analysis_basic_block_normal_form.py
@@ -211,4 +211,4 @@ def test_higher_order_nested():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/relay/test_analysis_extract_intermediate_expr.py b/tests/python/relay/test_analysis_extract_intermediate_expr.py
index abcaf880b4..57585552b4 100644
--- a/tests/python/relay/test_analysis_extract_intermediate_expr.py
+++ b/tests/python/relay/test_analysis_extract_intermediate_expr.py
@@ -127,4 +127,4 @@ def test_extract():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/relay/test_analysis_extract_operators.py b/tests/python/relay/test_analysis_extract_operators.py
index 5878b2a6e4..5218fbf700 100644
--- a/tests/python/relay/test_analysis_extract_operators.py
+++ b/tests/python/relay/test_analysis_extract_operators.py
@@ -104,4 +104,4 @@ def test_extract_resnet():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/relay/test_auto_scheduler_task_extraction.py b/tests/python/relay/test_auto_scheduler_task_extraction.py
index a53b68cca8..9dbc653da2 100644
--- a/tests/python/relay/test_auto_scheduler_task_extraction.py
+++ b/tests/python/relay/test_auto_scheduler_task_extraction.py
@@ -291,4 +291,4 @@ def test_custom_hash_func_extract_tasks():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/relay/test_backend_graph_executor.py b/tests/python/relay/test_backend_graph_executor.py
index 0522c0db10..179077e874 100644
--- a/tests/python/relay/test_backend_graph_executor.py
+++ b/tests/python/relay/test_backend_graph_executor.py
@@ -527,4 +527,4 @@ def test_benchmark_end_to_end_rpc():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/relay/test_backend_interpreter.py b/tests/python/relay/test_backend_interpreter.py
index af2dcf32c3..3c94452311 100644
--- a/tests/python/relay/test_backend_interpreter.py
+++ b/tests/python/relay/test_backend_interpreter.py
@@ -286,4 +286,4 @@ def test_functional_returns():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/relay/test_call_graph.py b/tests/python/relay/test_call_graph.py
index a597824890..26106c31d5 100644
--- a/tests/python/relay/test_call_graph.py
+++ b/tests/python/relay/test_call_graph.py
@@ -145,4 +145,4 @@ def test_recursive_func():
 
 
 if __name__ == "__main__":
-    pytest.main()
+    tvm.testing.main()
diff --git a/tests/python/relay/test_name_mangling.py b/tests/python/relay/test_name_mangling.py
index 7b0a60f745..46195d1fa2 100644
--- a/tests/python/relay/test_name_mangling.py
+++ b/tests/python/relay/test_name_mangling.py
@@ -35,4 +35,4 @@ def test_mangle_mod_name():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/relay/test_op_grad_level2.py b/tests/python/relay/test_op_grad_level2.py
index 820f724bfc..32e7d2ca38 100644
--- a/tests/python/relay/test_op_grad_level2.py
+++ b/tests/python/relay/test_op_grad_level2.py
@@ -364,4 +364,4 @@ def test_conv2d_backward_weight_infer_type():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/relay/test_op_grad_level3.py b/tests/python/relay/test_op_grad_level3.py
index 89b8199b9e..4ca7cb9ce0 100644
--- a/tests/python/relay/test_op_grad_level3.py
+++ b/tests/python/relay/test_op_grad_level3.py
@@ -194,4 +194,4 @@ def test_zeros_ones_grad_dynamic(executor_kind):
 
 
 if __name__ == "__main__":
-    pytest.main()
+    tvm.testing.main()
diff --git a/tests/python/relay/test_op_grad_level4.py b/tests/python/relay/test_op_grad_level4.py
index 9ed2ef2627..b85e692c5f 100644
--- a/tests/python/relay/test_op_grad_level4.py
+++ b/tests/python/relay/test_op_grad_level4.py
@@ -123,4 +123,4 @@ def test_strided_slice_grad(executor_kind):
 
 
 if __name__ == "__main__":
-    pytest.main()
+    tvm.testing.main()
diff --git a/tests/python/relay/test_op_level1.py b/tests/python/relay/test_op_level1.py
index 9f31acfa6d..3bb9918c7c 100644
--- a/tests/python/relay/test_op_level1.py
+++ b/tests/python/relay/test_op_level1.py
@@ -911,4 +911,4 @@ def test_extern_concat_injective_fuse():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/relay/test_op_level6.py b/tests/python/relay/test_op_level6.py
index 78db5b8738..47cf73d691 100644
--- a/tests/python/relay/test_op_level6.py
+++ b/tests/python/relay/test_op_level6.py
@@ -173,4 +173,4 @@ def test_searchsorted():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/relay/test_pass_alter_op_layout.py b/tests/python/relay/test_pass_alter_op_layout.py
index 3fd7cb6977..4caab0ea09 100644
--- a/tests/python/relay/test_pass_alter_op_layout.py
+++ b/tests/python/relay/test_pass_alter_op_layout.py
@@ -1948,4 +1948,4 @@ def test_alter_with_reduce():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/relay/test_pass_convert_op_layout.py b/tests/python/relay/test_pass_convert_op_layout.py
index 223926a877..72d0232100 100644
--- a/tests/python/relay/test_pass_convert_op_layout.py
+++ b/tests/python/relay/test_pass_convert_op_layout.py
@@ -2786,4 +2786,4 @@ def test_conv_l2n_convert_layout():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/relay/test_pass_defunctionalization.py b/tests/python/relay/test_pass_defunctionalization.py
index 30f2203be0..a01c1c7e39 100644
--- a/tests/python/relay/test_pass_defunctionalization.py
+++ b/tests/python/relay/test_pass_defunctionalization.py
@@ -227,4 +227,4 @@ def @main(%l: List[int32]) -> int32 {
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/relay/test_pass_defuse_ops.py b/tests/python/relay/test_pass_defuse_ops.py
index f123bd582b..ec6431ee26 100644
--- a/tests/python/relay/test_pass_defuse_ops.py
+++ b/tests/python/relay/test_pass_defuse_ops.py
@@ -212,4 +212,4 @@ def test_defuse_complex():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/relay/test_pass_dynamic_to_static.py b/tests/python/relay/test_pass_dynamic_to_static.py
index f523ad2a27..7d492b4fc3 100644
--- a/tests/python/relay/test_pass_dynamic_to_static.py
+++ b/tests/python/relay/test_pass_dynamic_to_static.py
@@ -638,4 +638,4 @@ def test_dynamic_to_static_dynamic_if():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/relay/test_pass_flexible_shape_dispatch.py b/tests/python/relay/test_pass_flexible_shape_dispatch.py
index a6d547f4f5..86ccb25db5 100644
--- a/tests/python/relay/test_pass_flexible_shape_dispatch.py
+++ b/tests/python/relay/test_pass_flexible_shape_dispatch.py
@@ -116,4 +116,4 @@ def test_multiple_outputs():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/relay/test_pass_fuse_ops.py b/tests/python/relay/test_pass_fuse_ops.py
index fe662a3076..06c93fbc55 100644
--- a/tests/python/relay/test_pass_fuse_ops.py
+++ b/tests/python/relay/test_pass_fuse_ops.py
@@ -829,4 +829,4 @@ def test_fuse_softmax():
 
 
 if __name__ == "__main__":
-    pytest.main([__pfile__])
+    tvm.testing.main()
diff --git a/tests/python/relay/test_pass_gradient.py b/tests/python/relay/test_pass_gradient.py
index 126fcf22e8..33f0775b2d 100644
--- a/tests/python/relay/test_pass_gradient.py
+++ b/tests/python/relay/test_pass_gradient.py
@@ -457,4 +457,4 @@ def test_global_function():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/relay/test_pass_inline.py b/tests/python/relay/test_pass_inline.py
index fb58b9032e..f5898774f5 100644
--- a/tests/python/relay/test_pass_inline.py
+++ b/tests/python/relay/test_pass_inline.py
@@ -827,4 +827,4 @@ def test_callee_not_inline_leaf_inline_extern_compiler():
 
 
 if __name__ == "__main__":
-    pytest.main()
+    tvm.testing.main()
diff --git a/tests/python/relay/test_pass_lambda_lift.py b/tests/python/relay/test_pass_lambda_lift.py
index ce737b7bed..518a8c3078 100644
--- a/tests/python/relay/test_pass_lambda_lift.py
+++ b/tests/python/relay/test_pass_lambda_lift.py
@@ -83,4 +83,4 @@ def test_recursive():
 
 
 if __name__ == "__main__":
-    pytest.main()
+    tvm.testing.main()
diff --git a/tests/python/relay/test_pass_manager.py b/tests/python/relay/test_pass_manager.py
index c7926f7a3d..4088cfdef0 100644
--- a/tests/python/relay/test_pass_manager.py
+++ b/tests/python/relay/test_pass_manager.py
@@ -614,4 +614,4 @@ def test_print_debug_callback():
 
 
 if __name__ == "__main__":
-    pytest.main()
+    tvm.testing.main()
diff --git a/tests/python/relay/test_pass_merge_composite.py b/tests/python/relay/test_pass_merge_composite.py
index 06cb1ecde7..eefec17aa3 100644
--- a/tests/python/relay/test_pass_merge_composite.py
+++ b/tests/python/relay/test_pass_merge_composite.py
@@ -980,4 +980,4 @@ def test_type_check():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/relay/test_pass_remove_unused_functions.py b/tests/python/relay/test_pass_remove_unused_functions.py
index 0764a88b31..67efc9b202 100644
--- a/tests/python/relay/test_pass_remove_unused_functions.py
+++ b/tests/python/relay/test_pass_remove_unused_functions.py
@@ -121,4 +121,4 @@ def test_call_globalvar_without_args():
 
 
 if __name__ == "__main__":
-    pytest.main()
+    tvm.testing.main()
diff --git a/tests/python/relay/test_pass_simplify_expr.py b/tests/python/relay/test_pass_simplify_expr.py
index fa9773b8e3..ad0b33551c 100644
--- a/tests/python/relay/test_pass_simplify_expr.py
+++ b/tests/python/relay/test_pass_simplify_expr.py
@@ -745,4 +745,4 @@ def test_simplify_add():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/relay/test_pass_to_basic_block_normal_form.py b/tests/python/relay/test_pass_to_basic_block_normal_form.py
index d04afe15b5..2a97e985d9 100644
--- a/tests/python/relay/test_pass_to_basic_block_normal_form.py
+++ b/tests/python/relay/test_pass_to_basic_block_normal_form.py
@@ -514,4 +514,4 @@ def test_immutability():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/relay/test_pass_unmatched_cases.py b/tests/python/relay/test_pass_unmatched_cases.py
index 255cecf76f..885f260251 100644
--- a/tests/python/relay/test_pass_unmatched_cases.py
+++ b/tests/python/relay/test_pass_unmatched_cases.py
@@ -467,4 +467,4 @@ def @expand_on_empty_tuple_match(%a: (List[()], ())) -> int {
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/relay/test_pipeline_executor.py b/tests/python/relay/test_pipeline_executor.py
index 0f9d3633c5..3d71fdfc1d 100644
--- a/tests/python/relay/test_pipeline_executor.py
+++ b/tests/python/relay/test_pipeline_executor.py
@@ -624,4 +624,4 @@ def test_pipeline():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/relay/test_tensor_array.py b/tests/python/relay/test_tensor_array.py
index 21043abb3c..4973fa20c4 100644
--- a/tests/python/relay/test_tensor_array.py
+++ b/tests/python/relay/test_tensor_array.py
@@ -782,4 +782,4 @@ def test_static_tensor_get_data():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/relay/test_to_mixed_precision.py b/tests/python/relay/test_to_mixed_precision.py
index 51d040c311..771d366df0 100644
--- a/tests/python/relay/test_to_mixed_precision.py
+++ b/tests/python/relay/test_to_mixed_precision.py
@@ -538,4 +538,4 @@ def test_convert_follow_node_with_integer_arguments(target_precision):
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/relay/test_type_infer.py b/tests/python/relay/test_type_infer.py
index b0b7ef0481..13d164c2ca 100644
--- a/tests/python/relay/test_type_infer.py
+++ b/tests/python/relay/test_type_infer.py
@@ -583,6 +583,4 @@ def test_argreduce_infer_return_type():
 
 
 if __name__ == "__main__":
-    import sys
-
-    pytest.main(sys.argv)
+    tvm.testing.main()
diff --git a/tests/python/relay/test_vm_serialization.py b/tests/python/relay/test_vm_serialization.py
index 1a49fc5a01..f5a495bc71 100644
--- a/tests/python/relay/test_vm_serialization.py
+++ b/tests/python/relay/test_vm_serialization.py
@@ -316,4 +316,4 @@ def test_dynamic_bcast():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/unittest/test_aot_legalize_packed_call.py b/tests/python/unittest/test_aot_legalize_packed_call.py
index 106e0f52ad..3f6e3f776c 100644
--- a/tests/python/unittest/test_aot_legalize_packed_call.py
+++ b/tests/python/unittest/test_aot_legalize_packed_call.py
@@ -115,4 +115,4 @@ def test_aot_packed_call():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/unittest/test_arith_deduce_bound.py b/tests/python/unittest/test_arith_deduce_bound.py
index ef478b4c2f..0915df3051 100644
--- a/tests/python/unittest/test_arith_deduce_bound.py
+++ b/tests/python/unittest/test_arith_deduce_bound.py
@@ -234,4 +234,4 @@ def test_deduce_non_support():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/unittest/test_arith_rewrite_simplify.py b/tests/python/unittest/test_arith_rewrite_simplify.py
index d6c2cfe8bb..975af097c0 100644
--- a/tests/python/unittest/test_arith_rewrite_simplify.py
+++ b/tests/python/unittest/test_arith_rewrite_simplify.py
@@ -1071,4 +1071,4 @@ def test_if_then_else_simplify():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/unittest/test_arith_solve_linear_equations.py b/tests/python/unittest/test_arith_solve_linear_equations.py
index 87aea26e66..24eb860c55 100644
--- a/tests/python/unittest/test_arith_solve_linear_equations.py
+++ b/tests/python/unittest/test_arith_solve_linear_equations.py
@@ -178,4 +178,4 @@ def test_ill_formed():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/unittest/test_arith_solve_linear_inequality.py b/tests/python/unittest/test_arith_solve_linear_inequality.py
index 9fbe98fe57..dd2fbdf72b 100644
--- a/tests/python/unittest/test_arith_solve_linear_inequality.py
+++ b/tests/python/unittest/test_arith_solve_linear_inequality.py
@@ -197,4 +197,4 @@ def test_no_solution():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/unittest/test_ir_container.py b/tests/python/unittest/test_ir_container.py
index 3652d5bdb2..1915849e10 100644
--- a/tests/python/unittest/test_ir_container.py
+++ b/tests/python/unittest/test_ir_container.py
@@ -113,4 +113,4 @@ def test_ndarray_container():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/unittest/test_micro_model_library_format.py b/tests/python/unittest/test_micro_model_library_format.py
index 7ccaf72b1b..e8ffed8206 100644
--- a/tests/python/unittest/test_micro_model_library_format.py
+++ b/tests/python/unittest/test_micro_model_library_format.py
@@ -633,4 +633,4 @@ def test_multiple_relay_modules_aot_graph():
 
 
 if __name__ == "__main__":
-    sys.exit(pytest.main([__file__] + sys.argv[1:]))
+    tvm.testing.main()
diff --git a/tests/python/unittest/test_target_codegen_cuda.py b/tests/python/unittest/test_target_codegen_cuda.py
index 96b947e206..e60138a9c8 100644
--- a/tests/python/unittest/test_target_codegen_cuda.py
+++ b/tests/python/unittest/test_target_codegen_cuda.py
@@ -1045,4 +1045,4 @@ def test_try_unaligned_vector_load():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/unittest/test_tir_analysis_stmt_finding.py b/tests/python/unittest/test_tir_analysis_stmt_finding.py
index acb5faa0de..72fb4898be 100644
--- a/tests/python/unittest/test_tir_analysis_stmt_finding.py
+++ b/tests/python/unittest/test_tir_analysis_stmt_finding.py
@@ -51,4 +51,4 @@ def test_no_anchor_block():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/unittest/test_tir_buffer.py b/tests/python/unittest/test_tir_buffer.py
index d250fada6a..55c8316739 100644
--- a/tests/python/unittest/test_tir_buffer.py
+++ b/tests/python/unittest/test_tir_buffer.py
@@ -277,4 +277,4 @@ def test_buffer_broadcast_expr():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/unittest/test_tir_nodes.py b/tests/python/unittest/test_tir_nodes.py
index c4ab76cd26..83cd64fa22 100644
--- a/tests/python/unittest/test_tir_nodes.py
+++ b/tests/python/unittest/test_tir_nodes.py
@@ -525,4 +525,4 @@ def test_tir_allocate():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/unittest/test_tir_te_extern_primfunc.py b/tests/python/unittest/test_tir_te_extern_primfunc.py
index a622f77cc7..f6eb2e8a9b 100644
--- a/tests/python/unittest/test_tir_te_extern_primfunc.py
+++ b/tests/python/unittest/test_tir_te_extern_primfunc.py
@@ -222,4 +222,4 @@ def tensors_from_extern_op(extern, func):
 
 
 if __name__ == "__main__":
-    sys.exit(pytest.main(sys.argv))
+    tvm.testing.main()
diff --git a/tests/python/unittest/test_tir_transform_convert_for_loops_serial.py b/tests/python/unittest/test_tir_transform_convert_for_loops_serial.py
index e08f04fa1f..1bf21d5c59 100644
--- a/tests/python/unittest/test_tir_transform_convert_for_loops_serial.py
+++ b/tests/python/unittest/test_tir_transform_convert_for_loops_serial.py
@@ -59,4 +59,4 @@ def test_nn_conv2d_add_fixed_point_multiply_clip_cast_cast_2():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/unittest/test_tir_transform_hoist_if.py b/tests/python/unittest/test_tir_transform_hoist_if.py
index 0270500828..dd10e15853 100644
--- a/tests/python/unittest/test_tir_transform_hoist_if.py
+++ b/tests/python/unittest/test_tir_transform_hoist_if.py
@@ -809,4 +809,4 @@ def test_hoisting_op_conv():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/unittest/test_tir_transform_inject_rolling_buffer.py b/tests/python/unittest/test_tir_transform_inject_rolling_buffer.py
index 2e2b03ba72..70c14b02f0 100644
--- a/tests/python/unittest/test_tir_transform_inject_rolling_buffer.py
+++ b/tests/python/unittest/test_tir_transform_inject_rolling_buffer.py
@@ -277,4 +277,4 @@ def test_rolling_buffer_ir_transform():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/unittest/test_tir_transform_ir_utils.py b/tests/python/unittest/test_tir_transform_ir_utils.py
index 0946b32cca..d2cae35161 100644
--- a/tests/python/unittest/test_tir_transform_ir_utils.py
+++ b/tests/python/unittest/test_tir_transform_ir_utils.py
@@ -37,4 +37,4 @@ def test_convert_ssa():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/unittest/test_tir_transform_lower_warp_memory.py b/tests/python/unittest/test_tir_transform_lower_warp_memory.py
index 13f3a5ff7b..48af3ebaf5 100644
--- a/tests/python/unittest/test_tir_transform_lower_warp_memory.py
+++ b/tests/python/unittest/test_tir_transform_lower_warp_memory.py
@@ -349,4 +349,4 @@ def test_lower_warp_memory_divide_by_factor():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/unittest/test_tir_transform_make_unpacked_api.py b/tests/python/unittest/test_tir_transform_make_unpacked_api.py
index e5f41e7b52..245ff53f91 100644
--- a/tests/python/unittest/test_tir_transform_make_unpacked_api.py
+++ b/tests/python/unittest/test_tir_transform_make_unpacked_api.py
@@ -135,4 +135,4 @@ def test_body():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__])
+    tvm.testing.main()
diff --git a/tests/python/unittest/test_tir_usmp_analysis_extract_bufferinfo.py b/tests/python/unittest/test_tir_usmp_analysis_extract_bufferinfo.py
index 52880e40cb..662f86479c 100644
--- a/tests/python/unittest/test_tir_usmp_analysis_extract_bufferinfo.py
+++ b/tests/python/unittest/test_tir_usmp_analysis_extract_bufferinfo.py
@@ -1690,4 +1690,4 @@ def test_multiple_calls_to_same_primfunc():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__] + sys.argv[1:])
+    tvm.testing.main()
diff --git a/tests/python/unittest/test_tir_usmp_transform_convert_pool_allocations_to_offsets.py b/tests/python/unittest/test_tir_usmp_transform_convert_pool_allocations_to_offsets.py
index d1f86814e7..25e8955735 100644
--- a/tests/python/unittest/test_tir_usmp_transform_convert_pool_allocations_to_offsets.py
+++ b/tests/python/unittest/test_tir_usmp_transform_convert_pool_allocations_to_offsets.py
@@ -622,4 +622,4 @@ def test_tensor_intrin():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__] + sys.argv[1:])
+    tvm.testing.main()
diff --git a/tests/python/unittest/test_tir_usmp_utils.py b/tests/python/unittest/test_tir_usmp_utils.py
index 756b97b0d2..0fece9dcd2 100644
--- a/tests/python/unittest/test_tir_usmp_utils.py
+++ b/tests/python/unittest/test_tir_usmp_utils.py
@@ -198,4 +198,4 @@ def test_create_array_buffer_info():
 
 
 if __name__ == "__main__":
-    pytest.main([__file__] + sys.argv[1:])
+    tvm.testing.main()
diff --git a/tests/python/unittest/test_type_annotation_checker.py b/tests/python/unittest/test_type_annotation_checker.py
index 204c153313..9af356b971 100644
--- a/tests/python/unittest/test_type_annotation_checker.py
+++ b/tests/python/unittest/test_type_annotation_checker.py
@@ -22,6 +22,7 @@ from typing import Dict, List, Tuple, Union, Callable
 import pytest
 import _pytest
 
+import tvm
 from tvm.tir.schedule._type_checker import type_checked
 
 
@@ -187,4 +188,4 @@ def test_not_matches(type_annotation, case):
 
 
 if __name__ == "__main__":
-    sys.exit(pytest.main(sys.argv))
+    tvm.testing.main()