From 24b3f090c005ee3d9b892814aab65e21a1783ea8 Mon Sep 17 00:00:00 2001 From: Juan Garcia Bonilla Date: Wed, 5 Jun 2024 22:03:01 -0700 Subject: [PATCH] Add test for protectAllClassesRaises --- src/tests/test_protectAllClasses.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/tests/test_protectAllClasses.py diff --git a/src/tests/test_protectAllClasses.py b/src/tests/test_protectAllClasses.py new file mode 100644 index 0000000000..17c92722d4 --- /dev/null +++ b/src/tests/test_protectAllClasses.py @@ -0,0 +1,20 @@ + +from Basilisk.moduleTemplates import cModuleTemplate +from Basilisk.moduleTemplates import cppModuleTemplate + +import numpy.testing as npt + +def test_protectAllClassesRaises(): + mod1 = cModuleTemplate.cModuleTemplate() + mod2 = cppModuleTemplate.CppModuleTemplate() + + expected_ex = "You tried to add this variable(.*)" + + with npt.assert_raises_regex(ValueError, expected_ex): + mod1.error = "error" + + with npt.assert_raises_regex(ValueError, expected_ex): + mod2.error = "error" + +if __name__ == "__main__": + test_protectAllClassesRaises()