summaryrefslogtreecommitdiffstats
path: root/Lib/test/support
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-06-11 16:26:23 (GMT)
committerGitHub <noreply@github.com>2020-06-11 16:26:23 (GMT)
commit311110abcd8ab648dbf1803e36a8ba5d93fa019b (patch)
tree728d5fbcba944115a19d567e8e869d7ffcffe787 /Lib/test/support
parentbcd7deed9118e365c1225de2a2e1a81bf988c6ab (diff)
downloadcpython-311110abcd8ab648dbf1803e36a8ba5d93fa019b.zip
cpython-311110abcd8ab648dbf1803e36a8ba5d93fa019b.tar.gz
cpython-311110abcd8ab648dbf1803e36a8ba5d93fa019b.tar.bz2
bpo-40275: Move TransientResource to test_urllib2net (GH-20812)
Move TransientResource, time_out, socket_peer_reset and ioerror_peer_reset from test.support to test_urllib2net. Remove "import errno" from test.support.
Diffstat (limited to 'Lib/test/support')
-rw-r--r--Lib/test/support/__init__.py35
1 files changed, 0 insertions, 35 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index fa54ebe..f078ad7 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -4,7 +4,6 @@ if __name__ != 'test.support':
raise ImportError('support must be imported from the test package')
import contextlib
-import errno
import functools
import os
import re
@@ -49,7 +48,6 @@ __all__ = [
"is_resource_enabled", "requires", "requires_freebsd_version",
"requires_linux_version", "requires_mac_ver",
"check_syntax_error",
- "TransientResource", "time_out", "socket_peer_reset", "ioerror_peer_reset",
"BasicTestRunner", "run_unittest", "run_doctest",
"requires_gzip", "requires_bz2", "requires_lzma",
"bigmemtest", "bigaddrspacetest", "cpython_only", "get_attribute",
@@ -551,39 +549,6 @@ def open_urlresource(url, *args, **kw):
raise TestFailed('invalid resource %r' % fn)
-class TransientResource(object):
-
- """Raise ResourceDenied if an exception is raised while the context manager
- is in effect that matches the specified exception and attributes."""
-
- def __init__(self, exc, **kwargs):
- self.exc = exc
- self.attrs = kwargs
-
- def __enter__(self):
- return self
-
- def __exit__(self, type_=None, value=None, traceback=None):
- """If type_ is a subclass of self.exc and value has attributes matching
- self.attrs, raise ResourceDenied. Otherwise let the exception
- propagate (if any)."""
- if type_ is not None and issubclass(self.exc, type_):
- for attr, attr_value in self.attrs.items():
- if not hasattr(value, attr):
- break
- if getattr(value, attr) != attr_value:
- break
- else:
- raise ResourceDenied("an optional resource is not available")
-
-# Context managers that raise ResourceDenied when various issues
-# with the Internet connection manifest themselves as exceptions.
-# XXX deprecate these and use transient_internet() instead
-time_out = TransientResource(OSError, errno=errno.ETIMEDOUT)
-socket_peer_reset = TransientResource(OSError, errno=errno.ECONNRESET)
-ioerror_peer_reset = TransientResource(OSError, errno=errno.ECONNRESET)
-
-
@contextlib.contextmanager
def captured_output(stream_name):
"""Return a context manager used by captured_stdout/stdin/stderr