mirror of
https://github.com/python/cpython.git
synced 2025-12-04 08:34:25 +00:00
Add regrtest check for caches in packaging.database (see #12167)
This commit is contained in:
parent
1079bdfde3
commit
76558e12ad
1 changed files with 24 additions and 0 deletions
|
|
@ -173,6 +173,7 @@ import io
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import packaging.database
|
||||||
import platform
|
import platform
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
|
|
@ -967,6 +968,7 @@ class saved_test_environment:
|
||||||
'sys.warnoptions', 'threading._dangling',
|
'sys.warnoptions', 'threading._dangling',
|
||||||
'multiprocessing.process._dangling',
|
'multiprocessing.process._dangling',
|
||||||
'sysconfig._CONFIG_VARS', 'sysconfig._SCHEMES',
|
'sysconfig._CONFIG_VARS', 'sysconfig._SCHEMES',
|
||||||
|
'packaging.database_caches',
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_sys_argv(self):
|
def get_sys_argv(self):
|
||||||
|
|
@ -1054,6 +1056,28 @@ class saved_test_environment:
|
||||||
# Can't easily revert the logging state
|
# Can't easily revert the logging state
|
||||||
pass
|
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):
|
def get_sys_warnoptions(self):
|
||||||
return id(sys.warnoptions), sys.warnoptions, sys.warnoptions[:]
|
return id(sys.warnoptions), sys.warnoptions, sys.warnoptions[:]
|
||||||
def restore_sys_warnoptions(self, saved_options):
|
def restore_sys_warnoptions(self, saved_options):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue