summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-08-16 00:28:05 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-08-16 00:28:05 (GMT)
commitb14ac8c2b0eb949b896d5df2831b3e01e06cb7cb (patch)
tree5ecd1fa2f85f6764406708743166744e3054c525
parented9863685f6e93d62775c0ef4c8ce82eedf67f67 (diff)
downloadcpython-b14ac8c2b0eb949b896d5df2831b3e01e06cb7cb.zip
cpython-b14ac8c2b0eb949b896d5df2831b3e01e06cb7cb.tar.gz
cpython-b14ac8c2b0eb949b896d5df2831b3e01e06cb7cb.tar.bz2
Save and restore the global asyncore.socket_map, and warn if a test modified it
-rwxr-xr-xLib/test/regrtest.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index 48bfb5b..9c4584c 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -814,7 +814,7 @@ class saved_test_environment:
resources = ('sys.argv', 'cwd', 'sys.stdin', 'sys.stdout', 'sys.stderr',
'os.environ', 'sys.path', 'sys.path_hooks', '__import__',
- 'warnings.filters')
+ 'warnings.filters', 'asyncore.socket_map')
def get_sys_argv(self):
return id(sys.argv), sys.argv, sys.argv[:]
@@ -872,6 +872,15 @@ class saved_test_environment:
warnings.filters = saved_filters[1]
warnings.filters[:] = saved_filters[2]
+ def get_asyncore_socket_map(self):
+ asyncore = sys.modules.get('asyncore')
+ return asyncore and asyncore.socket_map or {}
+ def restore_asyncore_socket_map(self, saved_map):
+ asyncore = sys.modules.get('asyncore')
+ if asyncore is not None:
+ asyncore.socket_map.clear()
+ asyncore.socket_map.update(saved_map)
+
def resource_info(self):
for name in self.resources:
method_suffix = name.replace('.', '_')