testing_utils.py

Define utils for use in testing.

openmdao.utils.testing_utils.use_tempdirs(cls)[source]

Decorate each test in a unittest.TestCase so it runs in its own directory.

TestCase methods setUp and tearDown are replaced with _new_setup and _new_teardown, above. Method _new_setup creates a temporary directory in which to run the test, stores it in self.tempdir, and then calls the original setUp method. Method _new_teardown first runs the original tearDown method, and then returns to the original starting directory and deletes the temporary directory.

Parameters
clsTestCase

TestCase being decorated to use a tempdir for each test.

Returns
TestCase

The decorated TestCase class.