Преглед на файлове

Get rid of bogus output during test runs.

Chris McDonough преди 17 години
родител
ревизия
5a98b0ed01
променени са 4 файла, в които са добавени 7 реда и са изтрити 6 реда
  1. 2 2
      src/supervisor/childutils.py
  2. 1 2
      src/supervisor/memmon.py
  3. 3 1
      src/supervisor/tests/test_childutils.py
  4. 1 1
      src/supervisor/tests/test_memmon.py

+ 2 - 2
src/supervisor/childutils.py

@@ -60,8 +60,8 @@ class ProcessCommunicationsProtocol:
 pcomm = ProcessCommunicationsProtocol()
 
 class EventListenerProtocol:
-    def wait(self, stdin=sys.stdin):
-        self.ready()
+    def wait(self, stdin=sys.stdin, stdout=sys.stdout):
+        self.ready(stdout)
         line = stdin.readline()
         headers = get_headers(line)
         payload = stdin.read(int(headers['len']))

+ 1 - 2
src/supervisor/memmon.py

@@ -79,7 +79,6 @@ def usage():
 def shell(cmd):
     return os.popen(cmd).read()
 
-
 class Memmon:
     def __init__(self, programs, groups, any, sendmail, email, rpc):
         self.programs = programs
@@ -98,7 +97,7 @@ class Memmon:
         while 1:
             # we explicitly use self.stdin, self.stdout, and self.stderr
             # instead of sys.* so we can unit test this code
-            headers, payload = childutils.listener.wait(self.stdin)
+            headers, payload = childutils.listener.wait(self.stdin, self.stdout)
 
             if not headers['eventname'].startswith('TICK'):
                 # do nothing with non-TICK events

+ 3 - 1
src/supervisor/tests/test_childutils.py

@@ -85,9 +85,11 @@ class TestEventListenerProtocol(unittest.TestCase):
             def read(self, *ignored):
                 return 'hello'
         stdin = Dummy()
-        headers, payload = listener.wait(stdin)
+        stdout = StringIO()
+        headers, payload = listener.wait(stdin, stdout)
         self.assertEqual(headers, {'len':'5'})
         self.assertEqual(payload, 'hello')
+        self.assertEqual(stdout.getvalue(), 'READY\n')
 
     def test_token(self):
         from supervisor.childutils import listener

+ 1 - 1
src/supervisor/tests/test_memmon.py

@@ -13,7 +13,7 @@ class MemmonTests(unittest.TestCase):
     def _makeOnePopulated(self, programs, groups, any):
         from supervisor.tests.base import DummyRPCServer
         rpc = DummyRPCServer()
-        sendmail = 'echo'
+        sendmail = 'cat - > /dev/null'
         email = 'chrism@plope.com'
         memmon = self._makeOne(programs, groups, any, sendmail, email, rpc)
         memmon.stdin = StringIO()