Best Python code snippet using tempest_python
test_caching.py
Source:test_caching.py
...16 assert mgr.exists("test")17 assert isinstance(cache, set)18 assert isinstance(cache, cmk_base.caching.SetCache)19 assert isinstance(cache, cmk_base.caching.Cache)20def test_create_list_cache():21 mgr = cmk_base.caching.CacheManager()22 assert not mgr.exists("test")23 cache = mgr.get_list("test")24 assert mgr.exists("test")25 assert isinstance(cache, list)26 assert isinstance(cache, cmk_base.caching.ListCache)27 assert isinstance(cache, cmk_base.caching.Cache)28def test_clear_all():29 mgr = cmk_base.caching.CacheManager()30 list_cache = mgr.get_list("test_list")31 assert list_cache.is_empty()32 list_cache.append("123")33 list_cache += [ "1", "2" ]34 assert not list_cache.is_empty()...
ex_06_01.py
Source:ex_06_01.py
1"""2This is my version of Russian roulette.3"""4import random5import time6bullet = {7 'bullet_0': 'â',8 'bullet_1': 'â',9 'bullet_2': 'â',10 'bullet_3': 'â',11 'bullet_4': 'â',12 'bullet_5': 'â',13}14def shift(lst, steps):15 if steps < 0:16 steps = abs(steps)17 for i in range(steps):18 lst.append(lst.pop(0))19 else:20 for i in range(steps):21 lst.insert(0, lst.pop())22def print_drum():23 print(" â¼")24 print(f" {cache.get(list_cache[0])} ")25 print(f" {cache.get(list_cache[5])} {cache.get(list_cache[1])}")26 print(" â")27 print(f" {cache.get(list_cache[4])} {cache.get(list_cache[2])}")28 print(f" {cache.get(list_cache[3])} ")29 print('*' * 20)30 time.sleep(1.5)31cache = bullet.copy()32list_cache = list(cache)33dead = random.choice(range(6))34bullet['bullet_' + str(dead)] = 135print_drum()36while True:37 steps = random.choice(range(-6, 7))38 shift(list_cache, steps)39 if bullet.get(list_cache[0]) == 1:40 cache[list_cache[0]] = 'â'41 print("Sorry, you're a little bit dead ð")42 print_drum()43 break44 cache[list_cache[0]] = 'â'...
캐시_손초능.py
Source:캐시_손초능.py
1def solution(cacheSize, cities):2 list_cache, answer, n = [], 0, len(cities)3 if cacheSize:4 for i in range(n):5 for j in range(len(list_cache)):6 if capi(cities[i]) == list_cache[j]: # ëìê° cache ìì ìì ë7 temp = list_cache.pop(j)8 list_cache.append(temp)9 answer += 110 break11 else: # ëìê° cache ìì ìì ë12 if capi(cities[i]) not in list_cache:13 if len(list_cache) == cacheSize:14 list_cache.pop(0)15 list_cache.append(capi(cities[i]))16 else:17 list_cache.append(capi(cities[i]))18 answer += 519 else: return n * 5 # cache í¬ê¸°ê° 0 ì¼ ë, íì cache miss ì´ë¯ë¡20 return answer21def capi(string): # ë문ìë¡ ë°ê¾¸ë í¨ì22 list_str = list(map(str, string))23 for i in range(len(string)):24 list_str[i] = list_str[i].capitalize()...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!