diff options
author | Raymond Hettinger <python@rcn.com> | 2009-06-04 00:11:54 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2009-06-04 00:11:54 (GMT) |
commit | 686057b8facb474a4542a2236f6ca2de7aa04cb5 (patch) | |
tree | ea013d9fa7c2f2d483be38493fd27c4e6d4aa191 /Lib/test/support.py | |
parent | a678d94d589021363139182e1e8e2f58f319eed7 (diff) | |
download | cpython-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.py | 12 |
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 |