[Piglit] [PATCH 14/20] unittests: fix monitoring tests.
Dylan Baker
dylan at pnwbakers.com
Wed Jun 1 23:50:21 UTC 2016
The context managers were a bit odd in these tests. Some of them called
the close method (defeating the whole point of the context manager. This
patch makes the context managers actually correct, which keeps these
tests from breaking with the next commit.
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
unittests/monitoring_tests.py | 31 +++++++++++++------------------
1 file changed, 13 insertions(+), 18 deletions(-)
diff --git a/unittests/monitoring_tests.py b/unittests/monitoring_tests.py
index 158fcb5..b2364bc 100644
--- a/unittests/monitoring_tests.py
+++ b/unittests/monitoring_tests.py
@@ -56,7 +56,7 @@ class TestMonitoring(object):
self.monitoring = monitoring.Monitoring(False)
def test_Monitoring_delete_rule(self):
- """monitorin.Monitoring: add and delete rule."""
+ """monitoring.Monitoring: add and delete rule."""
with utils.nose.tempfile(self.init_contents) as tfile:
self.monitoring.add_rule('error_file',
@@ -65,11 +65,10 @@ class TestMonitoring(object):
self.regex)
self.monitoring.update_monitoring()
- self.monitoring.delete_rule('error_file')
- with open(tfile, 'w') as fp:
- fp.write(self.error_contents)
- fp.close()
- self.monitoring.check_monitoring()
+ self.monitoring.delete_rule('error_file')
+ with open(tfile, 'w') as fp:
+ fp.write(self.error_contents)
+ self.monitoring.check_monitoring()
nt.assert_equal(self.monitoring.abort_needed, False)
@@ -93,9 +92,8 @@ class TestMonitoring(object):
self.regex)
self.monitoring.update_monitoring()
- with open(tfile, 'w') as fp:
- fp.write(self.error_contents)
- fp.close()
+ with open(tfile, 'w') as fp:
+ fp.write(self.error_contents)
self.monitoring.check_monitoring()
nt.assert_equal(self.monitoring.abort_needed, True)
@@ -110,9 +108,8 @@ class TestMonitoring(object):
self.regex)
self.monitoring.update_monitoring()
- with open(tfile, 'w') as fp:
- fp.write(self.no_error_contents)
- fp.close()
+ with open(tfile, 'w') as fp:
+ fp.write(self.no_error_contents)
self.monitoring.check_monitoring()
nt.assert_equal(self.monitoring.abort_needed, False)
@@ -127,9 +124,8 @@ class TestMonitoring(object):
self.regex)
self.monitoring.update_monitoring()
- with open(tfile, 'w') as fp:
- fp.write(self.error_contents)
- fp.close()
+ with open(tfile, 'w') as fp:
+ fp.write(self.error_contents)
self.monitoring.check_monitoring()
nt.assert_equal(self.monitoring.abort_needed, True)
@@ -144,9 +140,8 @@ class TestMonitoring(object):
self.regex)
self.monitoring.update_monitoring()
- with open(tfile, 'w') as fp:
- fp.write(self.no_error_contents)
- fp.close()
+ with open(tfile, 'w') as fp:
+ fp.write(self.no_error_contents)
self.monitoring.check_monitoring()
nt.assert_equal(self.monitoring.abort_needed, False)
--
2.8.3
More information about the Piglit
mailing list