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
def test(status=False):
if os.environ.get('TRAVIS') == 'true':
return
if os.environ.get('APPVEYOR') == 'True':
return
random.seed(SEED)
deque = dc.Deque(range(SIZE))
processes = []
for count in range(8):
process = mp.Process(target=stress, args=(SEED + count, deque))
process.start()
processes.append(process)
for value in it.count():
time.sleep(1)
if status:
print('\r', value, 's', len(deque), 'items', ' ' * 20, end='')
if all(not process.is_alive() for process in processes):
break
def test_init():
directory = '/tmp/diskcache/deque'
sequence = list('abcde')
deque = dc.Deque(sequence, None)
assert deque == sequence
rmdir(deque.directory)
del deque
rmdir(directory)
deque = dc.Deque(sequence, directory)
assert deque.directory == directory
assert deque == sequence
other = dc.Deque(directory=directory)
assert other == deque
def test_init():
directory = '/tmp/diskcache/deque'
sequence = list('abcde')
deque = dc.Deque(sequence, None)
assert deque == sequence
rmdir(deque.directory)
del deque
rmdir(directory)
deque = dc.Deque(sequence, directory)
assert deque.directory == directory
assert deque == sequence
other = dc.Deque(directory=directory)
assert other == deque
del deque
del other
rmdir(directory)
def test_init(cache):
for key, value in dc.DEFAULT_SETTINGS.items():
assert getattr(cache, key) == value
cache.check()
for key, value in dc.DEFAULT_SETTINGS.items():
setattr(cache, key, value)
cache.check()
def test_init(cache):
default_settings = dc.DEFAULT_SETTINGS.copy()
del default_settings['size_limit']
for key, value in default_settings.items():
assert getattr(cache, key) == value
assert cache.size_limit == 2 ** 27
cache.check()
for key, value in dc.DEFAULT_SETTINGS.items():
setattr(cache, key, value)
cache.check()
def test_init(cache):
for key, value in dc.DEFAULT_SETTINGS.items():
assert getattr(cache, key) == value
cache.check()
cache.close()
cache.close()
def test_init(cache):
default_settings = dc.DEFAULT_SETTINGS.copy()
del default_settings['size_limit']
for key, value in default_settings.items():
assert getattr(cache, key) == value
assert cache.size_limit == 2 ** 27
cache.check()
for key, value in dc.DEFAULT_SETTINGS.items():
setattr(cache, key, value)
cache.check()
def test_init(cache):
for key, value in dc.DEFAULT_SETTINGS.items():
assert getattr(cache, key) == value
cache.check()
for key, value in dc.DEFAULT_SETTINGS.items():
setattr(cache, key, value)
cache.check()