Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ff91306

Browse files
committed
Add a regrtest cleanup check for shutil registries
1 parent a2b89e3 commit ff91306

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

Lib/test/regrtest.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@
165165
import platform
166166
import random
167167
import re
168+
import shutil
168169
import sys
169170
import sysconfig
170171
import tempfile
@@ -887,6 +888,7 @@ def __init__(self, testname, verbose=0, quiet=False):
887888
'os.environ', 'sys.path', 'sys.path_hooks', '__import__',
888889
'warnings.filters', 'asyncore.socket_map',
889890
'logging._handlers', 'logging._handlerList',
891+
'shutil.archive_formats', 'shutil.unpack_formats',
890892
'sys.warnoptions', 'threading._dangling',
891893
'multiprocessing.process._dangling')
892894

@@ -956,6 +958,23 @@ def restore_asyncore_socket_map(self, saved_map):
956958
asyncore.close_all(ignore_all=True)
957959
asyncore.socket_map.update(saved_map)
958960

961+
def get_shutil_archive_formats(self):
962+
# we could call get_archives_formats() but that only returns the
963+
# registry keys; we want to check the values too (the functions that
964+
# are registered)
965+
return shutil._ARCHIVE_FORMATS, shutil._ARCHIVE_FORMATS.copy()
966+
def restore_shutil_archive_formats(self, saved):
967+
shutil._ARCHIVE_FORMATS = saved[0]
968+
shutil._ARCHIVE_FORMATS.clear()
969+
shutil._ARCHIVE_FORMATS.update(saved[1])
970+
971+
def get_shutil_unpack_formats(self):
972+
return shutil._UNPACK_FORMATS, shutil._UNPACK_FORMATS.copy()
973+
def restore_shutil_unpack_formats(self, saved):
974+
shutil._UNPACK_FORMATS = saved[0]
975+
shutil._UNPACK_FORMATS.clear()
976+
shutil._UNPACK_FORMATS.update(saved[1])
977+
959978
def get_logging__handlers(self):
960979
# _handlers is a WeakValueDictionary
961980
return id(logging._handlers), logging._handlers, logging._handlers.copy()

0 commit comments

Comments
 (0)