summaryrefslogtreecommitdiffstats
path: root/Lib/test/support.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2009-06-04 00:11:54 (GMT)
committerRaymond Hettinger <python@rcn.com>2009-06-04 00:11:54 (GMT)
commit686057b8facb474a4542a2236f6ca2de7aa04cb5 (patch)
treeea013d9fa7c2f2d483be38493fd27c4e6d4aa191 /Lib/test/support.py
parenta678d94d589021363139182e1e8e2f58f319eed7 (diff)
downloadcpython-686057b8facb474a4542a2236f6ca2de7aa04cb5.zip
cpython-686057b8facb474a4542a2236f6ca2de7aa04cb5.tar.gz
cpython-686057b8facb474a4542a2236f6ca2de7aa04cb5.tar.bz2
Use new form of with-statement instead of contextlib.nested().
Diffstat (limited to 'Lib/test/support.py')
-rw-r--r--Lib/test/support.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/Lib/test/support.py b/Lib/test/support.py
index bdc6b89..da81422 100644
--- a/Lib/test/support.py
+++ b/Lib/test/support.py
@@ -591,13 +591,11 @@ class TransientResource(object):
raise ResourceDenied("an optional resource is not available")
-def transient_internet():
- """Return a context manager that raises ResourceDenied when various issues
- with the Internet connection manifest themselves as exceptions."""
- time_out = TransientResource(IOError, errno=errno.ETIMEDOUT)
- socket_peer_reset = TransientResource(socket.error, errno=errno.ECONNRESET)
- ioerror_peer_reset = TransientResource(IOError, errno=errno.ECONNRESET)
- return contextlib.nested(time_out, socket_peer_reset, ioerror_peer_reset)
+# Context managers that raise ResourceDenied when various issues
+# with the Internet connection manifest themselves as exceptions.
+time_out = TransientResource(IOError, errno=errno.ETIMEDOUT)
+socket_peer_reset = TransientResource(socket.error, errno=errno.ECONNRESET)
+ioerror_peer_reset = TransientResource(IOError, errno=errno.ECONNRESET)
@contextlib.contextmanager