[Piglit] [PATCH] framework tests: Stop leaving temporary files
Dylan Baker
baker.dylan.c at gmail.com
Thu Oct 2 15:26:55 PDT 2014
There is an odd interaction between context manager and
nose.tools.raises and nose.tools.assert_raises, if the context manager
is initializes inside of the assert_raises the temporary files a folders
will not be cleaned up.
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
framework/tests/glsl_parser_test_tests.py | 15 ++++++++-------
framework/tests/results_tests.py | 4 ++--
framework/tests/run_parser_tests.py | 12 ++++++------
3 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/framework/tests/glsl_parser_test_tests.py b/framework/tests/glsl_parser_test_tests.py
index 5d3f61e..7b9e5d8 100644
--- a/framework/tests/glsl_parser_test_tests.py
+++ b/framework/tests/glsl_parser_test_tests.py
@@ -211,12 +211,13 @@ def test_bad_section_name():
'// new_awesome_key: foo\n'
'// [end config]\n')
- with nt.assert_raises(SystemExit) as e:
- _, name = _check_config(content)
+ with utils.with_tempfile(content) as tfile:
+ with nt.assert_raises(SystemExit) as e:
+ glsl.GLSLParserTest(tfile)
- nt.eq_(e.exception.message,
- 'Key new_awesome_key in file {0 is not a valid key for a '
- 'glslparser test config block'.format(name))
+ nt.eq_(e.exception.message,
+ 'Key new_awesome_key in file {0 is not a valid key for a '
+ 'glslparser test config block'.format(tfile))
def test_good_section_names():
@@ -236,8 +237,8 @@ def test_good_section_names():
def check_no_duplicates(content, dup):
""" Ensure that duplicate entries raise an error """
- with nt.assert_raises(SystemExit) as e:
- with utils.with_tempfile(content) as tfile:
+ with utils.with_tempfile(content) as tfile:
+ with nt.assert_raises(SystemExit) as e:
glsl.GLSLParserTest(tfile)
nt.eq_(
diff --git a/framework/tests/results_tests.py b/framework/tests/results_tests.py
index 0b4cd23..fa91c57 100644
--- a/framework/tests/results_tests.py
+++ b/framework/tests/results_tests.py
@@ -151,11 +151,11 @@ def test_update_results_old():
nt.assert_equal(res.results_version, results.CURRENT_JSON_VERSION)
- at nt.raises(AssertionError)
def test_resume_non_folder():
""" TestrunResult.resume doesn't accept a file """
with utils.with_tempfile('') as f:
- results.TestrunResult.resume(f)
+ with nt.assert_raises(AssertionError):
+ results.TestrunResult.resume(f)
def test_resume_load():
diff --git a/framework/tests/run_parser_tests.py b/framework/tests/run_parser_tests.py
index d355bb2..622e9f7 100644
--- a/framework/tests/run_parser_tests.py
+++ b/framework/tests/run_parser_tests.py
@@ -97,7 +97,6 @@ class TestBackend(_Helpers):
args = run._run_parser(['quick.py', 'foo'])
nt.assert_equal(args.backend, 'junit')
- @nt.raises(SystemExit)
def test_bad_value_in_conf(self):
""" run parser: an error is raised when the platform in conf is bad """
self._unset_config()
@@ -112,8 +111,9 @@ class TestBackend(_Helpers):
with open(os.path.join(tdir, 'piglit.conf'), 'w') as f:
f.write('[core]\nbackend=foobar')
- run._run_parser(['-f', os.path.join(tdir, 'piglit.conf'),
- 'quick.py', 'foo'])
+ with nt.assert_raises(SystemExit):
+ run._run_parser(['-f', os.path.join(tdir, 'piglit.conf'),
+ 'quick.py', 'foo'])
class TestPlatform(_Helpers):
@@ -190,7 +190,6 @@ class TestPlatform(_Helpers):
args = run._run_parser(['quick.py', 'foo'])
nt.assert_equal(args.platform, 'glx')
- @nt.raises(SystemExit)
def test_bad_value_in_conf(self):
""" run parser: an error is raised when the platform in conf is bad """
self._unset_config()
@@ -205,5 +204,6 @@ class TestPlatform(_Helpers):
with open(os.path.join(tdir, 'piglit.conf'), 'w') as f:
f.write('[core]\nplatform=foobar')
- run._run_parser(['-f', os.path.join(tdir, 'piglit.conf'),
- 'quick.py', 'foo'])
+ with nt.assert_raises(SystemExit):
+ run._run_parser(['-f', os.path.join(tdir, 'piglit.conf'),
+ 'quick.py', 'foo'])
--
2.1.1
More information about the Piglit
mailing list