diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-07-02 12:50:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-02 12:50:19 (GMT) |
commit | 7cb9204ee1cf204f6f507d99a60f7c5bb359eebb (patch) | |
tree | ae351690ede26e65b690c5802de6aa0a850894ee /Lib/test/libregrtest | |
parent | 039fb49c185570ab7b02f13fbdc51c859cfd831e (diff) | |
download | cpython-7cb9204ee1cf204f6f507d99a60f7c5bb359eebb.zip cpython-7cb9204ee1cf204f6f507d99a60f7c5bb359eebb.tar.gz cpython-7cb9204ee1cf204f6f507d99a60f7c5bb359eebb.tar.bz2 |
bpo-37421: urllib.request tests call urlcleanup() (GH-14529)
urllib.request tests now call urlcleanup() to remove temporary files
created by urlretrieve() tests and to clear the _opener global
variable set by urlopen() and functions calling indirectly urlopen().
regrtest now checks if urllib.request._url_tempfiles and
urllib.request._opener are changed by tests.
Diffstat (limited to 'Lib/test/libregrtest')
-rw-r--r-- | Lib/test/libregrtest/save_env.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/libregrtest/save_env.py b/Lib/test/libregrtest/save_env.py index 31931f2..e7c27a6 100644 --- a/Lib/test/libregrtest/save_env.py +++ b/Lib/test/libregrtest/save_env.py @@ -7,6 +7,7 @@ import shutil import sys import sysconfig import threading +import urllib.request import warnings from test import support from test.libregrtest.utils import print_warning @@ -68,8 +69,20 @@ class saved_test_environment: 'files', 'locale', 'warnings.showwarning', 'shutil_archive_formats', 'shutil_unpack_formats', 'asyncio.events._event_loop_policy', + 'urllib.requests._url_tempfiles', 'urllib.requests._opener', ) + def get_urllib_requests__url_tempfiles(self): + return list(urllib.request._url_tempfiles) + def restore_urllib_requests__url_tempfiles(self, tempfiles): + for filename in tempfiles: + support.unlink(filename) + + def get_urllib_requests__opener(self): + return urllib.request._opener + def restore_urllib_requests__opener(self, opener): + urllib.request._opener = opener + def get_asyncio_events__event_loop_policy(self): return support.maybe_get_event_loop_policy() def restore_asyncio_events__event_loop_policy(self, policy): |