Best Python code snippet using locust
test_system.py
Source:test_system.py  
...63        eqL_(container.objects[0].title,  'confirm.yes')64    def test_actual_resets():65        import mock66        @mock.patch.object(bridge.favorite, 'clear')67        def test_reset(reset_call):68            container = system.ResetFavorites()69            reset_call.assert_called_once_with()70            eqL_(container.header, 'heading.system')71            eqL_(container.message, 'system.response.reset-favorites')72        test_reset()73        @mock.patch.object(bridge.search, 'clear')74        def test_reset(reset_call):75            container = system.ResetSearches()76            reset_call.assert_called_once_with()77            eqL_(container.header, 'heading.system')78            eqL_(container.message, 'system.response.reset-search')79        test_reset()80        @mock.patch.object(bridge.download, 'clear_history')81        def test_reset(reset_call):82            container = system.ResetDownloads()83            reset_call.assert_called_once_with()84            eqL_(container.header, 'heading.system')85            eqL_(container.message, 'system.response.reset-download-history')86        test_reset()87        @mock.patch.object(bridge.download, 'clear_failed')88        def test_reset(reset_call):89            container = system.ResetDownloadsFailed()90            reset_call.assert_called_once_with()91            eqL_(container.header, 'heading.system')92            eqL_(container.message, 'system.response.reset-download-failed')93        test_reset()94        @mock.patch.object(system.ss.cache, 'reset')95        def test_reset(reset_call):96            container = system.ResetSSCache()97            reset_call.assert_called_once_with()98            eqL_(container.header, 'heading.system')99            eqL_(container.message, 'system.response.reset-ss-cache')100        test_reset()101        @mock.patch.object(system.Dict, 'Save')102        @mock.patch.object(system.Dict, 'Reset')103        @mock.patch.object(system.ss.cache, 'reset')104        def test_reset(*a):105            container = system.ResetFactory()106            for _m in a:107                _m.assert_called_once_with()108            eqL_(container.header, 'heading.system')109            eqL_(container.message, 'system.response.reset-factory')...tests.py
Source:tests.py  
...59            self.assertEqual(resultado, inicial + incremento)60        # También comprobamos que el valor se almacena correctamente tanto en el Getter del incrementador 61        # como en el propio resultado de este.62        self.assertEqual(test_incrementar.getIncrementador(), resultado) 63    def test_reset(self):64        """ Declaramos el contador que vamos a utilizar para el test """65        inicial = 066        incremento = 1067        limite = 5068        test_reset = Contador(inicial, incremento, limite)69        """ Utilizamos la funcion Incrementar para que incremente varias veces el valor del contador """70        test_reset.Incrementar()71        test_reset.Incrementar()72        test_reset.Incrementar()73        """ Una vez tenemos un valor decente, reseteamos el contador """74        test_reset.reset()75        """ Y ahora comprobamos que se ha reseteado correctamente """76        self.assertEqual(test_reset.getValorActual(), inicial) 77        self.assertEqual(test_reset.getValorActual(), test_reset.getValorInicial()) ...1030-1.py
Source:1030-1.py  
1# U X  íì¬ íìì  X칸 ìììëí2# D X íì¬ íìì X칸 ë°ììëí3# C íì¬ ì íë íì ìì í í, ë°ë¡ ìë íì ì íí©ëë¤. ë¨, ìì ë íì´ ê°ì¥ ë§ì§ë§ íì¸ ê²½ì° ë°ë¡ ì íì ì íí©ëë¤.4# Z ë§ì§ë§ì ìì í í 복구 ë¨, íì¬ ì íë íì ë°ëì§ ììµëë¤.5# "OOXOXOOO"6# í¨ì¨ì± 0ì 7import copy8class linked:9    def __init__(self, num):10        self.num = num11        self.left = None12        self.right = None13def solution(n, k, cmd):14    ans = linked(0)15    temp = linked(0)16    stack = []17    result = "O" * n18    # ì´ê¸°ì¤ì 19    for i in range(1, n):20        t = linked(i)21        t.left = temp22        temp.right = t23        temp = t24        if i == 1:25            ans.right = temp26    # 커ì ìì¹27    for i in range(k):28        test_reset = ans.right29        ans = test_reset30    # ëª
ë ¹ì´ ì²ë¦¬31    for c in cmd:32        if len(c) >= 2:33            # x ëª
ë ¹ì´  y:ì«ì34            x, y = c.split()35            y = int(y)36            if x == "D":37                for _ in range(y):38                    if ans.right == None:39                        break40                    test_reset = ans.right41                    ans = test_reset42            else:43                for _ in range(y):44                    if ans.left == None:45                        break46                    test_reset = ans.left47                    ans = test_reset48        # C49        elif c == "C":50            deleteIdx = ans51            if ans.right == None:52                ans = ans.left53                ans.right = None54            elif ans.left == None:55                ans = ans.right56                ans.left = None57            else:58                ans.left.right = ans.right59                ans.right.left = ans.left60                ans = ans.right61            stack.append(deleteIdx)62        else:  # Z63            value = stack.pop()64            if value.left != None:65                value.left.right = value66            if value.right != None:67                value.right.left = value68    result = list(result)69    for x in stack:70        result[x.num] = 'X'71    result = "".join(result)72    return result73n = [8, 8]74k = [2, 2]75cmd = [["D 2", "C", "U 3", "C", "D 4", "C", "U 2", "Z", "Z"],76       ["D 2", "C", "U 3", "C", "D 4", "C", "U 2", "Z", "Z", "U 1", "C"]]77for i in range(2):...1021.py
Source:1021.py  
1# U X  íì¬ íìì  X칸 ìììëí2# D X íì¬ íìì X칸 ë°ììëí3# C íì¬ ì íë íì ìì í í, ë°ë¡ ìë íì ì íí©ëë¤. ë¨, ìì ë íì´ ê°ì¥ ë§ì§ë§ íì¸ ê²½ì° ë°ë¡ ì íì ì íí©ëë¤.4# Z ë§ì§ë§ì ìì í í 복구 ë¨, íì¬ ì íë íì ë°ëì§ ììµëë¤.5# "OOXOXOOO"6# í¨ì¨ì± 0ì 7import copy8class linked:9    def __init__(self, num):10        self.num = num11        self.left = None12        self.right = None13def solution(n, k, cmd):14    ans = linked(0)15    temp = linked(0)16    stack = []17    result = "O" * n18    for i in range(1, n):19        t = linked(i)20        t.left = temp21        temp.right = t22        temp = t23        if i == 1:24            ans.right = temp25    test = copy.deepcopy(ans)26    for i in range(k):27        test_reset = test.right28        test = test_reset29    for c in cmd:30        if len(c) >= 2:31            # x ëª
ë ¹ì´  y:ì«ì32            x, y = c.split()33            y = int(y)34            if x == "D":35                for _ in range(y):36                    if test.right == None:37                        break38                    test_reset = test.right39                    test = test_reset40            else:41                for _ in range(y):42                    if test.left == None:43                        break44                    test_reset = test.left45                    test = test_reset46        # C47        elif c == "C":48            deleteIdx = test49            if test.right == None:50                test = test.left51                test.right = None52            elif test.left == None:53                test = test.right54                test.left = None55            else:56                test.left.right = test.right57                test.right.left = test.left58                test = test.right59            stack.append(deleteIdx)60        else:  # Z61            value = stack.pop()62            if value.left != None:63                value.left.right = value64            if value.right != None:65                value.right.left = value66    result = list(result)67    for x in stack:68        result[x.num] = 'X'69    result = "".join(result)70    return result71n = [8, 8]72k = [2, 2]73cmd = [["D 2", "C", "U 3", "C", "D 4", "C", "U 2", "Z", "Z"],74       ["D 2", "C", "U 3", "C", "D 4", "C", "U 2", "Z", "Z", "U 1", "C"]]75for i in range(2):...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!!
