From c97e22f1d570ddbb645ef17c93e48892febfbef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Sun, 6 Oct 2024 07:59:23 -0400 Subject: [PATCH] Guard unittest.main() invocation when test files are imported --- tests/testlex.py | 3 ++- tests/testyacc.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/testlex.py b/tests/testlex.py index 7f2adad..b98e4f7 100755 --- a/tests/testlex.py +++ b/tests/testlex.py @@ -398,4 +398,5 @@ def test_lex_state_try(self): -unittest.main() +if __name__ == "__main__": + unittest.main() diff --git a/tests/testyacc.py b/tests/testyacc.py index b488bf7..216df40 100644 --- a/tests/testyacc.py +++ b/tests/testyacc.py @@ -400,4 +400,5 @@ def test_yacc_prec1(self): "Precedence rule 'left' defined for unknown symbol '/'\n" )) -unittest.main() +if __name__ == "__main__": + unittest.main()