[Python-checkins] cpython: Add regrtest check for caches in packaging.database (see #12167)
eric.araujo
python-checkins at python.org
Thu Oct 6 13:24:13 CEST 2011
http://hg.python.org/cpython/rev/e76c6aaff135
changeset: 72738:e76c6aaff135
user: Éric Araujo <merwok at netwok.org>
date: Thu Oct 06 02:44:19 2011 +0200
summary:
Add regrtest check for caches in packaging.database (see #12167)
files:
Lib/test/regrtest.py | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -173,6 +173,7 @@
import json
import logging
import os
+import packaging.database
import platform
import random
import re
@@ -967,6 +968,7 @@
'sys.warnoptions', 'threading._dangling',
'multiprocessing.process._dangling',
'sysconfig._CONFIG_VARS', 'sysconfig._SCHEMES',
+ 'packaging.database_caches',
)
def get_sys_argv(self):
@@ -1054,6 +1056,28 @@
# Can't easily revert the logging state
pass
+ def get_packaging_database_caches(self):
+ # caching system used by the PEP 376 implementation
+ # we have one boolean and four dictionaries, initially empty
+ switch = packaging.database._cache_enabled
+ saved = []
+ for name in ('_cache_name', '_cache_name_egg',
+ '_cache_path', '_cache_path_egg'):
+ cache = getattr(packaging.database, name)
+ saved.append((id(cache), cache, cache.copy()))
+ return switch, saved
+ def restore_packaging_database_caches(self, saved):
+ switch, saved_caches = saved
+ packaging.database._cache_enabled = switch
+ for offset, name in enumerate(('_cache_name', '_cache_name_egg',
+ '_cache_path', '_cache_path_egg')):
+ _, cache, items = saved_caches[offset]
+ # put back the same object in place
+ setattr(packaging.database, name, cache)
+ # now restore its items
+ cache.clear()
+ cache.update(items)
+
def get_sys_warnoptions(self):
return id(sys.warnoptions), sys.warnoptions, sys.warnoptions[:]
def restore_sys_warnoptions(self, saved_options):
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list