[Python-checkins] r51629 - python/branches/hoxworth-stdlib_logging-soc/test_smtpd_logging.py

jackilyn.hoxworth python-checkins at python.org
Mon Aug 28 02:22:37 CEST 2006


Author: jackilyn.hoxworth
Date: Mon Aug 28 02:22:37 2006
New Revision: 51629

Added:
   python/branches/hoxworth-stdlib_logging-soc/test_smtpd_logging.py
Log:


Added: python/branches/hoxworth-stdlib_logging-soc/test_smtpd_logging.py
==============================================================================
--- (empty file)
+++ python/branches/hoxworth-stdlib_logging-soc/test_smtpd_logging.py	Mon Aug 28 02:22:37 2006
@@ -0,0 +1,23 @@
+import smtpd
+import logging
+from cStringIO import StringIO
+
+# ... run the tests ...
+log=logging.getLogger("py.smtpd")
+stringLog = StringIO()
+
+# define the handler and level
+handler = logging.StreamHandler(stringLog)
+log.setLevel(logging.INFO)
+
+# add the handler to the logger
+log.addHandler(handler)
+
+smtpd._log.info("message 1") 
+
+print stringLog.getvalue()  # For testing purposes
+
+if stringLog.getvalue() != "Error:  It worked":
+    print "it worked"
+else:
+    print "it didn't work"
\ No newline at end of file


More information about the Python-checkins mailing list