diff Lib/test/support.py @ 72400:a4e4facad164

Close issue 12958 by flagging expected failures in test_socket on Mac OS X
author Nick Coghlan <ncoghlan@gmail.com>
date Mon, 19 Sep 2011 20:26:31 +1000
parents b5a5bd429580
children 3b1859f80e6d
line wrap: on
line diff
--- a/Lib/test/support.py	Mon Sep 19 08:30:43 2011 +0200
+++ b/Lib/test/support.py	Mon Sep 19 20:26:31 2011 +1000
@@ -57,6 +57,7 @@
     "get_attribute", "swap_item", "swap_attr", "requires_IEEE_754",
     "TestHandler", "Matcher", "can_symlink", "skip_unless_symlink",
     "import_fresh_module", "requires_zlib", "PIPE_MAX_SIZE", "failfast",
+    "anticipate_failure"
     ]
 
 class Error(Exception):
@@ -127,6 +128,17 @@
     return saved
 
 
+def anticipate_failure(condition):
+    """Decorator to mark a test that is known to be broken in some cases
+
+       Any use of this decorator should have a comment identifying the
+       associated tracker issue.
+    """
+    if condition:
+        return unittest.expectedFailure
+    return lambda f: f
+
+
 def import_fresh_module(name, fresh=(), blocked=(), deprecated=False):
     """Imports and returns a module, deliberately bypassing the sys.modules cache
     and importing a fresh copy of the module. Once the import is complete,