summaryrefslogtreecommitdiffstats
path: root/Doc/lib
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2007-03-08 23:58:11 (GMT)
committerBrett Cannon <bcannon@gmail.com>2007-03-08 23:58:11 (GMT)
commita30fcb4dae51705f182383a6ad5f3fb86a80f9fb (patch)
treed704230a35802a5f1a745becf7b62acecfe377df /Doc/lib
parent9b2a10954037b30851322fac794ce098118f4f42 (diff)
downloadcpython-a30fcb4dae51705f182383a6ad5f3fb86a80f9fb.zip
cpython-a30fcb4dae51705f182383a6ad5f3fb86a80f9fb.tar.gz
cpython-a30fcb4dae51705f182383a6ad5f3fb86a80f9fb.tar.bz2
Introduce test.test_support.TransientResource. It's a context manager to
surround calls to resources that may or may not be available. Specifying the expected exception and attributes to be raised if the resource is not available prevents overly broad catching of exceptions. This is meant to help suppress spurious failures by raising test.test_support.ResourceDenied if the exception matches. It would probably be good to go through the various network tests and surround the calls to catch connection timeouts (as done with test_socket_ssl in this commit).
Diffstat (limited to 'Doc/lib')
-rw-r--r--Doc/lib/libtest.tex8
1 files changed, 8 insertions, 0 deletions
diff --git a/Doc/lib/libtest.tex b/Doc/lib/libtest.tex
index f30b49b..326c5f0 100644
--- a/Doc/lib/libtest.tex
+++ b/Doc/lib/libtest.tex
@@ -285,6 +285,14 @@ originated from.
The \module{test.test_support} module defines the following classes:
+\begin{classdesc}{TransientResource}{exc\optional{, **kwargs}}
+Create a context manager that raises \class{ResourceDenied} if the specified
+exception type is raised. Any keyword arguments are treated as name/value
+pairs to be compared against any exception raised with the \code{with}
+statement. Only if all pairs match is \class{ResourceDenied} raised.
+\versionadded{2.6}
+\end{classdesc}
+
\begin{classdesc}{EnvironmentVarGuard}{}
Class used to temporarily set or unset environment variables. Instances can be
used as a context manager.