23 Because OPAL is sloppy with memory, we run many tests in a forked process.
24 This is done by using EncapsulatedTestCase instead of the regular unittest
27 TestCases should inherit from this class. By default make install will put
28 the class in pyopal.objects. Individual test methods should have a name like
29 "encapsulated_test_<name>" to indicate that the method needs to be run in a
30 forked process. EncapsulatedTestCase will search for these tests at run time
35 Search through the methods and look for functions with name
36 "encapsulated_test_<name>". If one is found, it will be executed in a
39 This method replaces all of the encapsulated_test_<name> methods, so if
40 multiple iterations fail it still gets counted as a single failure.
42 for name, test_method
in vars(self.__class__).items():
43 if name[:18] !=
"encapsulated_test_":
45 if not callable(test_method):
52 print(
"Encapsulated test failed with:")
53 sys.excepthook(*sys.exc_info())
57 return_value = os.waitpid(a_pid, 0)[1]
58 classname = self.__class__.__name__
59 self.assertEqual(return_value, 0,
60 msg=f
"Failed test {classname}.{name}")
def test_run_encapsulated