diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2014-10-22 12:53:54 -0500 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2014-11-10 17:35:43 -0600 |
commit | b50d7b239f5b6530873df25a80dde484f955581c (patch) | |
tree | 94608f3d954da7f8a9d1f3aabecee13bfc1c3797 /testsuite/Testsrc/Testlib/TestOptions | |
parent | 4ec92cb9e7d1eb2f90d36e5255ee8814ca0a8513 (diff) | |
download | bcfg2-b50d7b239f5b6530873df25a80dde484f955581c.tar.gz bcfg2-b50d7b239f5b6530873df25a80dde484f955581c.tar.bz2 bcfg2-b50d7b239f5b6530873df25a80dde484f955581c.zip |
testsuite: unlink temporary files
This cleans up the temporary config files created by the option
parsing unit tests. Courtesy Alexander Sulfrian.
Diffstat (limited to 'testsuite/Testsrc/Testlib/TestOptions')
-rw-r--r-- | testsuite/Testsrc/Testlib/TestOptions/TestOptions.py | 9 | ||||
-rw-r--r-- | testsuite/Testsrc/Testlib/TestOptions/__init__.py | 6 |
2 files changed, 10 insertions, 5 deletions
diff --git a/testsuite/Testsrc/Testlib/TestOptions/TestOptions.py b/testsuite/Testsrc/Testlib/TestOptions/TestOptions.py index 9f4a7873c..94d30dd3a 100644 --- a/testsuite/Testsrc/Testlib/TestOptions/TestOptions.py +++ b/testsuite/Testsrc/Testlib/TestOptions/TestOptions.py @@ -400,9 +400,12 @@ class TestBasicOptions(OptionTestCase): fh.write("test") fh.close() - parser.parse(["-C", config_file, "--test", name]) - self.assertEqual(result.test.name, name) - self.assertEqual(result.test.read(), "test") + try: + parser.parse(["-C", config_file, "--test", name]) + self.assertEqual(result.test.name, name) + self.assertEqual(result.test.read(), "test") + finally: + os.unlink(name) @clean_environment @make_config() diff --git a/testsuite/Testsrc/Testlib/TestOptions/__init__.py b/testsuite/Testsrc/Testlib/TestOptions/__init__.py index ca2c41359..e92f95e94 100644 --- a/testsuite/Testsrc/Testlib/TestOptions/__init__.py +++ b/testsuite/Testsrc/Testlib/TestOptions/__init__.py @@ -32,8 +32,10 @@ class make_config(object): # pylint: disable=invalid-name config_file.close() args = list(args) + [name] - rv = func(*args, **kwargs) - os.unlink(name) + try: + rv = func(*args, **kwargs) + finally: + os.unlink(name) return rv return inner |