testinggtk r342 - trunk/tests



Author: bjornl
Date: Thu Jul 17 23:57:30 2008
New Revision: 342
URL: http://svn.gnome.org/viewvc/testinggtk?rev=342&view=rev

Log:
Decorator to supress warnings

Modified:
   trunk/tests/utils.py

Modified: trunk/tests/utils.py
==============================================================================
--- trunk/tests/utils.py	(original)
+++ trunk/tests/utils.py	Thu Jul 17 23:57:30 2008
@@ -19,6 +19,9 @@
     def push_stderr(self):
         sys.stderr = self.file
 
+    def pop_stderr(self):
+        sys.stderr = self.stderr
+
     def pop_stderr_and_fail_warnings(self):
         sys.stderr = self.stderr
         for triplet in self.get_warning_triplets():
@@ -74,7 +77,26 @@
     wrapper.__module__ = func.__module__
     wrapper.__name__ = func.__name__
     return wrapper
-    
+
+def swallow_warnings(func):
+    '''
+    A decorator that swallows any printouts on stderr.
+
+    .. python::
+
+       @utils.swallow_warnings
+       def test_blaha():
+           code that makes warnings...
+
+    :param func: test function to decorate           
+    '''
+    def wrapper():
+        wc.push_stderr()
+        func()
+        wc.pop_stderr()
+    wrapper.__module__ = func.__module__
+    wrapper.__name__ = func.__name__
+    return wrapper
 
 def gtk_process_all_pending_events():
     '''



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]