summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2016-06-01 14:39:23 -0700
committerDylan Baker <dylan@pnwbakers.com>2016-06-02 11:12:28 -0700
commite2bc6e2f63125542879172d36f92e7daba991360 (patch)
tree824b880274242d024eef646bae1670f7e98d095a
parent85370a0543ff0ccd2b306dd74892c15cba550cb9 (diff)
unittests: fix monitoring tests.
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@intel.com>
-rw-r--r--unittests/monitoring_tests.py31
1 files changed, 13 insertions, 18 deletions
diff --git a/unittests/monitoring_tests.py b/unittests/monitoring_tests.py
index 158fcb5fa..b2364bc4b 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)