[Zope3-checkins] CVS: Zope3/src/zope/configuration - fields.py:1.10

Philipp von Weitershausen philikon at philikon.de
Mon Aug 4 14:17:25 EDT 2003


Update of /cvs-repository/Zope3/src/zope/configuration
In directory cvs.zope.org:/tmp/cvs-serv10088

Modified Files:
	fields.py 
Log Message:
Improve the doc test according to Jim's suggestion.


=== Zope3/src/zope/configuration/fields.py 1.9 => 1.10 ===
--- Zope3/src/zope/configuration/fields.py:1.9	Mon Aug  4 12:57:39 2003
+++ Zope3/src/zope/configuration/fields.py	Mon Aug  4 13:17:20 2003
@@ -294,16 +294,28 @@
     >>> field = MessageID().bind(context)
 
     There is a fallback domain when no domain has been specified.
-    Suppress warnings so they won't show up when running unit tests.
 
-    >>> import warnings
-    >>> warnings.filterwarnings('ignore')
+    Exchange the warn function so we can make test whether the warning
+    has been issued
+
+    >>> warned = None
+    >>> def fakewarn(*args, **kw):
+    ...     global warned
+    ...     warned = args
 
+    >>> import warnings
+    >>> realwarn = warnings.warn
+    >>> warnings.warn = fakewarn
+    
     >>> i = field.fromUnicode(u"Hello world!")
     >>> i
     u'Hello world!'
     >>> i.domain
     'untranslated'
+    >>> warned
+    ("You did not specify an i18n translation domain for the '' field in file location",)
+
+    >>> warnings.warn = realwarn
 
     With the domain specified:
 
@@ -344,7 +356,8 @@
             domain = 'untranslated'
             warnings.warn(
                 "You did not specify an i18n translation domain for the "\
-                "'%s' field in %s" % (self.getName(), context.info ))
+                "'%s' field in %s" % (self.getName(), context.info )
+                )
         v = super(MessageID, self).fromUnicode(u)
 
         # Record the string we got for the domain




More information about the Zope3-Checkins mailing list