[Zope3-checkins] SVN: Zope3/trunk/src/zope/deprecation/ showwarning() monkey patch: Changed this to produce a line of output

Tim Peters tim.one at comcast.net
Mon Feb 14 23:00:27 EST 2005


Log message for revision 29144:
  showwarning() monkey patch:  Changed this to produce a line of output
  first saying that it comes from tests.py's showwarning().  I find the
  test output less surprising that way.
  
  Various doctests using that showwarning():  Changed to match the new
  output, which also allows using an ellipsis to suprress x-platform
  differences in the file path displayed.
  

Changed:
  U   Zope3/trunk/src/zope/deprecation/README.txt
  U   Zope3/trunk/src/zope/deprecation/tests.py

-=-
Modified: Zope3/trunk/src/zope/deprecation/README.txt
===================================================================
--- Zope3/trunk/src/zope/deprecation/README.txt	2005-02-14 22:43:16 UTC (rev 29143)
+++ Zope3/trunk/src/zope/deprecation/README.txt	2005-02-15 04:00:26 UTC (rev 29144)
@@ -15,10 +15,10 @@
   from zope.deprecation import deprecated
   demo1 = 1
   deprecated('demo1', 'demo1 is no more.')
-  
+
   demo2 = 2
   deprecated('demo2', 'demo2 is no more.')
-  
+
   demo3 = 3
   deprecated('demo3', 'demo3 is no more.')
 
@@ -32,13 +32,15 @@
 
   >>> from zope.deprecation import tests
   >>> tests.demo1
-  /.../README.txt:1: DeprecationWarning: demo1: demo1 is no more.
+  From tests.py's showwarning():
+  ...README.txt:1: DeprecationWarning: demo1: demo1 is no more.
   ...
   1
 
   >>> import zope.deprecation.tests
   >>> zope.deprecation.tests.demo2
-  /.../README.txt:1: DeprecationWarning: demo2: demo2 is no more.
+  From tests.py's showwarning():
+  ...README.txt:1: DeprecationWarning: demo2: demo2 is no more.
   ...
   2
 
@@ -48,7 +50,8 @@
 name directly, the deprecation warning will be raised immediately.
 
   >>> from zope.deprecation.tests import demo3
-  /.../README.txt:1: DeprecationWarning: demo3: demo3 is no more.
+  From tests.py's showwarning():
+  ...README.txt:1: DeprecationWarning: demo3: demo3 is no more.
   ...
 
 Also, once a deprecation warning has been displayed, it is not shown again:
@@ -81,13 +84,15 @@
 
   >>> my = MyComponent()
   >>> my.foo
-  /.../README.txt:1: DeprecationWarning: foo is no more.
+  From tests.py's showwarning():
+  ...README.txt:1: DeprecationWarning: foo is no more.
   ...
   1
   >>> my.bar
   2
   >>> my.blah()
-  /.../README.txt:1: DeprecationWarning: blah() is no more.
+  From tests.py's showwarning():
+  ...README.txt:1: DeprecationWarning: blah() is no more.
   ...
   3
   >>> my.splat()
@@ -113,7 +118,8 @@
   >>> foo = Foo()
 
   >>> foo.bar
-  /.../README.txt:1: DeprecationWarning: bar is no more.
+  From tests.py's showwarning():
+  ...README.txt:1: DeprecationWarning: bar is no more.
   ...
   1
 
@@ -164,4 +170,4 @@
   >>> __show__.on()
   Traceback (most recent call last):
   ...
-  IndexError: pop from empty list
\ No newline at end of file
+  IndexError: pop from empty list

Modified: Zope3/trunk/src/zope/deprecation/tests.py
===================================================================
--- Zope3/trunk/src/zope/deprecation/tests.py	2005-02-14 22:43:16 UTC (rev 29143)
+++ Zope3/trunk/src/zope/deprecation/tests.py	2005-02-15 04:00:26 UTC (rev 29144)
@@ -35,6 +35,7 @@
 orig_showwarning = warnings.showwarning
 
 def showwarning(message, category, filename, lineno, file=None):
+    sys.stdout.write("From tests.py's showwarning():\n")
     sys.stdout.write(
         warnings.formatwarning(message, category, filename, lineno))
 



More information about the Zope3-Checkins mailing list