Commit d7e626f3 authored by Trevor Cappallo's avatar Trevor Cappallo
Browse files

fix exit handler test

parent dbebf741
......@@ -61,13 +61,5 @@ class TestAll(unittest.TestCase):
ret = OpLog.log_shell(['diff', self.file_a, self.file_a])
assert ret == 0
def test_exit_handler_no_rcpts(self):
logging.error("exit handler test no rcpts")
s = StringIO.StringIO()
temp_buffer = logging.StreamHandler(s)
logging.getLogger().addHandler(temp_buffer)
atexit._run_exitfuncs()
assert "No recipients found. Email not sent" in s.getvalue()
if __name__ == '__main__':
unittest.main()
#!/usr/bin/env python
"""Unit tests for OperationalLogging."""
import unittest
from nose.tools import raises, eq_
import tempfile
import os
import os.path
import logging
import shutil
import atexit
import StringIO
import OperationalLogger as OpLog
import OperationalMail as OpMail
class TestExit(unittest.TestCase):
ab_diff = "1c1\n< alpha\n---\n> beta\n"
def setUp(self):
print '\n\n'
self.temp_dir = tempfile.mkdtemp()
self.log_dir = tempfile.mkdtemp()
self.file_a = os.path.join(self.temp_dir, 'a')
self.file_b = os.path.join(self.temp_dir, 'b')
with open(self.file_a, 'w') as f:
f.write('alpha\n')
with open(self.file_b, 'w') as f:
f.write('beta\n')
OpLog.setup(log_root_dir=self.log_dir)
def tearDown(self):
shutil.rmtree(self.temp_dir)
print '\n\n'
def test_exit_handler_no_rcpts(self):
logging.error("exit handler test no rcpts")
s = StringIO.StringIO()
temp_buffer = logging.StreamHandler(s)
h = logging.getLogger().addHandler(temp_buffer)
atexit._run_exitfuncs()
assert "No recipients found. Email not sent" in s.getvalue()
logging.getLogger().removeHandler(h)
if __name__ == '__main__':
unittest.main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment