[Python-checkins] r84086 - python/branches/py3k/Lib/test/regrtest.py

antoine.pitrou python-checkins at python.org
Mon Aug 16 02:28:05 CEST 2010


Author: antoine.pitrou
Date: Mon Aug 16 02:28:05 2010
New Revision: 84086

Log:
Save and restore the global asyncore.socket_map, and warn if a test modified it



Modified:
   python/branches/py3k/Lib/test/regrtest.py

Modified: python/branches/py3k/Lib/test/regrtest.py
==============================================================================
--- python/branches/py3k/Lib/test/regrtest.py	(original)
+++ python/branches/py3k/Lib/test/regrtest.py	Mon Aug 16 02:28:05 2010
@@ -814,7 +814,7 @@
 
     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 @@
         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('.', '_')


More information about the Python-checkins mailing list