Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_init():
directory = '/tmp/diskcache/index'
mapping = {'a': 5, 'b': 4, 'c': 3, 'd': 2, 'e': 1}
index = dc.Index(None, mapping)
assert index == mapping
rmdir(index.directory)
del index
rmdir(directory)
index = dc.Index(directory, mapping)
assert index.directory == directory
assert index == mapping
other = dc.Index(directory)
assert other == index
def test(status=False):
random.seed(SEED)
index = dc.Index(enumerate(range(KEYS)))
processes = []
for count in range(8):
process = mp.Process(target=stress, args=(SEED + count, index))
process.start()
processes.append(process)
for value in it.count():
time.sleep(1)
if status:
print('\r', value, 's', len(index), 'keys', ' ' * 20, end='')
if all(not process.is_alive() for process in processes):
break
directory = '/tmp/diskcache/index'
mapping = {'a': 5, 'b': 4, 'c': 3, 'd': 2, 'e': 1}
index = dc.Index(None, mapping)
assert index == mapping
rmdir(index.directory)
del index
rmdir(directory)
index = dc.Index(directory, mapping)
assert index.directory == directory
assert index == mapping
other = dc.Index(directory)
assert other == index
del index
del other
rmdir(directory)
index = dc.Index(directory, mapping.items())
assert index == mapping
del index
rmdir(directory)
index = dc.Index(directory, a=5, b=4, c=3, d=2, e=1)
assert index == mapping
assert index == mapping
other = dc.Index(directory)
assert other == index
del index
del other
rmdir(directory)
index = dc.Index(directory, mapping.items())
assert index == mapping
del index
rmdir(directory)
index = dc.Index(directory, a=5, b=4, c=3, d=2, e=1)
assert index == mapping
del index
rmdir(directory)
index = dc.Index(directory, mapping)
assert index.directory == directory
assert index == mapping
other = dc.Index(directory)
assert other == index
del index
del other
rmdir(directory)
index = dc.Index(directory, mapping.items())
assert index == mapping
del index
rmdir(directory)
index = dc.Index(directory, a=5, b=4, c=3, d=2, e=1)
assert index == mapping
def init_data(self, env):
from diskcache import Index
self.dbname = env.cr.dbname
self.UUID_OPENID = Index(self.get_path('UUID_OPENID'))
self.OPENID_UUID = Index(self.get_path('OPENID_UUID'))
self.OPENID_LAST = Index(self.get_path('OPENID_LAST'))
def init_data(self, env):
from diskcache import Index
self.dbname = env.cr.dbname
self.UUID_OPENID = Index(self.get_path('UUID_OPENID'))
self.OPENID_UUID = Index(self.get_path('OPENID_UUID'))
self.OPENID_LAST = Index(self.get_path('OPENID_LAST'))