[Supervisor-checkins] r887 - in supervisor/trunk/src/supervisor: . tests

Chris McDonough chrism at agendaless.com
Sat Sep 5 15:30:42 EDT 2009


Author: Chris McDonough <chrism at agendaless.com>
Date: Sat Sep  5 15:30:41 2009
New Revision: 887

Log:
Test get_asctime.


Modified:
   supervisor/trunk/src/supervisor/childutils.py
   supervisor/trunk/src/supervisor/tests/test_childutils.py

Modified: supervisor/trunk/src/supervisor/childutils.py
==============================================================================
--- supervisor/trunk/src/supervisor/childutils.py	(original)
+++ supervisor/trunk/src/supervisor/childutils.py	Sat Sep  5 15:30:41 2009
@@ -38,8 +38,9 @@
     headers = get_headers(headerinfo)
     return headers, data
 
-def get_asctime():
-    now = time.time()
+def get_asctime(now=None):
+    if now is None: # for testing
+        now = time.time()
     msecs = (now - long(now)) * 1000
     part1 = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(now))
     asctime = '%s,%03d' % (part1, msecs)

Modified: supervisor/trunk/src/supervisor/tests/test_childutils.py
==============================================================================
--- supervisor/trunk/src/supervisor/tests/test_childutils.py	(original)
+++ supervisor/trunk/src/supervisor/tests/test_childutils.py	Sat Sep  5 15:30:41 2009
@@ -38,6 +38,11 @@
         self.assertEqual(headers, {'a':'1', 'b':'2'})
         self.assertEqual(data, 'thedata\n')
 
+    def test_get_asctime(self):
+        from supervisor.childutils import get_asctime
+        result = get_asctime(2147483647)
+        self.assertEqual(result, '2038-01-18 22:14:07,000')
+
 class TestProcessCommunicationsProtocol(unittest.TestCase):
     def test_send(self):
         from supervisor.childutils import pcomm


More information about the Supervisor-checkins mailing list