Chris McDonough преди 15 години
родител
ревизия
1ab09e1009
променени са 2 файла, в които са добавени 8 реда и са изтрити 2 реда
  1. 3 2
      src/supervisor/childutils.py
  2. 5 0
      src/supervisor/tests/test_childutils.py

+ 3 - 2
src/supervisor/childutils.py

@@ -38,8 +38,9 @@ def eventdata(payload):
     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)

+ 5 - 0
src/supervisor/tests/test_childutils.py

@@ -38,6 +38,11 @@ class ChildUtilsTests(unittest.TestCase):
         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