Browse Source

improve dispatchers module coverage

Chris McDonough 11 years ago
parent
commit
20b202044f
2 changed files with 41 additions and 2 deletions
  1. 0 2
      supervisor/dispatchers.py
  2. 41 0
      supervisor/tests/test_dispatchers.py

+ 0 - 2
supervisor/dispatchers.py

@@ -427,8 +427,6 @@ class PEventListenerDispatcher(PDispatcher):
             if self.state_buffer:
                 # keep going til its too short
                 self.handle_listener_state_change()
-            else:
-                return
 
     def handle_result(self, result):
         process = self.process

+ 41 - 0
supervisor/tests/test_dispatchers.py

@@ -9,6 +9,34 @@ from supervisor.tests.base import DummyLogger
 from supervisor.tests.base import DummyEvent
 from supervisor import read_file
 
+class PDispatcherTests(unittest.TestCase):
+    def setUp(self):
+        from supervisor.events import clear
+        clear()
+
+    def tearDown(self):
+        from supervisor.events import clear
+        clear()
+
+    def _getTargetClass(self):
+        from supervisor.dispatchers import PDispatcher
+        return PDispatcher
+
+    def _makeOne(self, process=None, channel='stdout', fd=0):
+        return self._getTargetClass()(process, channel, fd)
+    
+    def test_readable(self):
+        inst = self._makeOne()
+        self.assertRaises(NotImplementedError, inst.readable)
+        
+    def test_writable(self):
+        inst = self._makeOne()
+        self.assertRaises(NotImplementedError, inst.writable)
+
+    def test_flush(self):
+        inst = self._makeOne()
+        self.assertEqual(inst.flush(), None)
+        
 class POutputDispatcherTests(unittest.TestCase):
     def setUp(self):
         from supervisor.events import clear
@@ -468,6 +496,19 @@ class POutputDispatcherTests(unittest.TestCase):
         self.assertEqual(dispatcher.closed, True)
 
 
+    def test_syslog_logfile_deprecated(self):
+        import warnings
+        options = DummyOptions()
+        config = DummyPConfig(options, 'process1', '/bin/process1')
+        config.stdout_logfile = 'syslog'
+        process = DummyProcess(config)
+        with warnings.catch_warnings(record=True) as w:
+            self._makeOne(process)
+            self.assertEqual(len(w), 1)
+        
+        
+
+
 class PInputDispatcherTests(unittest.TestCase):
     def _getTargetClass(self):
         from supervisor.dispatchers import PInputDispatcher