[CalendarServer-changes] [11372] CalendarServer/trunk/twext/python/test/test_log.py

source_changes at macosforge.org source_changes at macosforge.org
Fri Jun 14 17:09:20 PDT 2013


Revision: 11372
          http://trac.calendarserver.org//changeset/11372
Author:   wsanchez at apple.com
Date:     2013-06-14 17:09:20 -0700 (Fri, 14 Jun 2013)
Log Message:
-----------
Add test_formatEventYouSoNasty

Modified Paths:
--------------
    CalendarServer/trunk/twext/python/test/test_log.py

Modified: CalendarServer/trunk/twext/python/test/test_log.py
===================================================================
--- CalendarServer/trunk/twext/python/test/test_log.py	2013-06-15 00:08:40 UTC (rev 11371)
+++ CalendarServer/trunk/twext/python/test/test_log.py	2013-06-15 00:09:20 UTC (rev 11372)
@@ -228,7 +228,8 @@
             self.assertIdentical(type(result), unicode)
             return result
 
-        self.assertEquals(u"", format(""))
+        self.assertEquals(u"", format(b""))
+        self.assertEquals(u"", format(u""))
         self.assertEquals(u"abc", format("{x}", x="abc"))
         self.assertEquals(u"no, yes.",
                           format("{not_called}, {called()}.",
@@ -263,6 +264,35 @@
         self.assertIn(repr(event), result)
 
 
+    def test_formatEventYouSoNasty(self):
+        """
+        Formatting an event that's just plain out to get us.
+        """
+        event = dict(log_format="{evil()}", evil=lambda: 1/0)
+        result = formatEvent(event)
+
+        self.assertIn("Unable to format event", result)
+        self.assertIn(repr(event), result)
+
+
+#     def test_formatEventYouSoNastyOMGMakeItStop(self):
+#         """
+#         Formatting an event that's just plain out to get us and is
+#         really determined.
+#         """
+#         badRepr = 
+
+#         event = dict(
+#             log_format="{evil()}",
+#             evil=lambda: 1/0,
+#         )
+#         result = formatEvent(event)
+
+#         self.assertIn("Unable to format event", result)
+#         self.assertIn(repr(event), result)
+
+
+
 class LoggerTests(SetUpTearDown, TestCase):
     """
     Tests for L{Logger}.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130614/bc3f04ed/attachment.html>


More information about the calendarserver-changes mailing list