Permalink
Browse files

Bug 792412 - Add test for multiple LoggerListener attached to a Mozmi…

…ll instance
  • Loading branch information...
1 parent f53ca04 commit 4169f06687d0c8804cf410c883f63681ddf80bb9 @whimboo whimboo committed Sep 21, 2012
Showing with 44 additions and 0 deletions.
  1. +43 −0 mutt/mutt/tests/python/test_loggerlistener.py
  2. +1 −0 mutt/mutt/tests/python/tests.ini
@@ -0,0 +1,43 @@
+from cStringIO import StringIO
+import os
+import sys
+import unittest
+import tempfile
+
+import mozmill
+from mozmill.logger import LoggerListener
+
+
+class ModuleTest(unittest.TestCase):
+ def make_test(self):
+ """make an example test to run"""
+ test = """var test_something = function() {}"""
+ fd, path = tempfile.mkstemp()
+ os.write(fd, test)
+ os.close(fd)
+
+ return path
+
+ def test_logger_listener(self):
+ tests = [{'path': self.make_test()}]
+
+ info_data= StringIO()
+ debug_data = StringIO()
+
+ logger_info = LoggerListener(console_level="INFO", console_stream=info_data)
+ logger_debug = LoggerListener(console_level="DEBUG", console_stream=debug_data)
+
+ m = mozmill.MozMill.create(handlers=(logger_info, logger_debug))
+ results = m.run(tests)
+ results.finish((logger_info, logger_debug))
+
+ assert "TEST-START" in debug_data.getvalue()
+ assert "TEST-PASS" in debug_data.getvalue()
+ assert "DEBUG" in debug_data.getvalue()
+
+ assert "TEST-START" in debug_data.getvalue()
+ assert "TEST-PASS" in debug_data.getvalue()
+ assert "DEBUG" not in info_data.getvalue()
+
+if __name__ == '__main__':
+ unittest.main()
@@ -6,6 +6,7 @@ type = python
[expectstacktest.py]
[test_bug690154.py]
[test_endTest.py]
+[test_loggerListener.py]
[testapi.py]
[testmultiplerun.py]
[testpersisted.py]

0 comments on commit 4169f06

Please sign in to comment.