Best Python code snippet using locust
test_tags.py
Source:test_tags.py  
...82            def excluded(self):83                pass84            @tag("dont exclude this", "other tag")85            @task86            def not_excluded(self):87                pass88            @task89            def dont_exclude_this_either(self):90                pass91        self.assertListEqual(92            MyTaskSet.tasks, [MyTaskSet.excluded, MyTaskSet.not_excluded, MyTaskSet.dont_exclude_this_either]93        )94        filter_tasks_by_tags(MyTaskSet, exclude_tags=set(["exclude this"]))95        self.assertListEqual(MyTaskSet.tasks, [MyTaskSet.not_excluded, MyTaskSet.dont_exclude_this_either])96    def test_including_and_excluding(self):97        class MyTaskSet(TaskSet):98            @task99            def not_included_or_excluded(self):100                pass101            @tag("included")102            @task103            def included(self):104                pass105            @tag("excluded")106            @task107            def excluded(self):108                pass109            @tag("included", "excluded")110            @task111            def included_and_excluded(self):112                pass113        filter_tasks_by_tags(MyTaskSet, tags=set(["included"]), exclude_tags=set(["excluded"]))114        self.assertListEqual(MyTaskSet.tasks, [MyTaskSet.included])115    def test_including_tasksets(self):116        class MyTaskSet(TaskSet):117            @task118            class MixedNestedTaskSet(TaskSet):119                @tag("included")120                @task121                def included(self):122                    pass123                @task124                def not_included(self):125                    pass126            @tag("included")127            @task128            class TaggedNestedTaskSet(TaskSet):129                @task130                def included(self):131                    pass132            @task133            class NormalNestedTaskSet(TaskSet):134                @task135                def not_included(self):136                    pass137        filter_tasks_by_tags(MyTaskSet, tags=set(["included"]))138        self.assertListEqual(MyTaskSet.tasks, [MyTaskSet.MixedNestedTaskSet, MyTaskSet.TaggedNestedTaskSet])139        self.assertListEqual(MyTaskSet.MixedNestedTaskSet.tasks, [MyTaskSet.MixedNestedTaskSet.included])140    def test_excluding_tasksets(self):141        class MyTaskSet(TaskSet):142            @task143            class MixedNestedTaskSet(TaskSet):144                @tag("excluded")145                @task146                def excluded(self):147                    pass148                @task149                def not_excluded(self):150                    pass151            @task152            class ExcludedNestedTaskSet(TaskSet):153                @tag("excluded")154                @task155                def excluded(self):156                    pass157            @tag("excluded")158            @task159            class TaggedNestedTaskSet(TaskSet):160                @task161                def excluded(self):162                    pass163            @task164            class NormalNestedTaskSet(TaskSet):165                @task166                def not_excluded(self):167                    pass168        filter_tasks_by_tags(MyTaskSet, exclude_tags=set(["excluded"]))169        self.assertListEqual(MyTaskSet.tasks, [MyTaskSet.MixedNestedTaskSet, MyTaskSet.NormalNestedTaskSet])170        self.assertListEqual(MyTaskSet.MixedNestedTaskSet.tasks, [MyTaskSet.MixedNestedTaskSet.not_excluded])171    def test_including_tags_with_weights(self):172        class MyTaskSet(TaskSet):173            @tag("included")174            @task(2)175            def include_twice(self):176                pass177            @tag("included")178            @task(3)179            def include_3_times(self):180                pass181            @tag("dont include this")182            @task(4)183            def dont_include_4_times(self):184                pass185            @task(5)186            def dont_include_5_times(self):187                pass188        self.assertListEqual(189            MyTaskSet.tasks,190            [191                MyTaskSet.include_twice,192                MyTaskSet.include_twice,193                MyTaskSet.include_3_times,194                MyTaskSet.include_3_times,195                MyTaskSet.include_3_times,196                MyTaskSet.dont_include_4_times,197                MyTaskSet.dont_include_4_times,198                MyTaskSet.dont_include_4_times,199                MyTaskSet.dont_include_4_times,200                MyTaskSet.dont_include_5_times,201                MyTaskSet.dont_include_5_times,202                MyTaskSet.dont_include_5_times,203                MyTaskSet.dont_include_5_times,204                MyTaskSet.dont_include_5_times,205            ],206        )207        filter_tasks_by_tags(MyTaskSet, tags=set(["included"]))208        self.assertListEqual(209            MyTaskSet.tasks,210            [211                MyTaskSet.include_twice,212                MyTaskSet.include_twice,213                MyTaskSet.include_3_times,214                MyTaskSet.include_3_times,215                MyTaskSet.include_3_times,216            ],217        )218    def test_excluding_tags_with_weights(self):219        class MyTaskSet(TaskSet):220            @tag("dont exclude this")221            @task(2)222            def dont_exclude_twice(self):223                pass224            @task(3)225            def dont_exclude_3_times(self):226                pass227            @tag("excluded")228            @task(4)229            def exclude_4_times(self):230                pass231            @tag("excluded")232            @task(5)233            def exclude_5_times(self):234                pass235        self.assertListEqual(236            MyTaskSet.tasks,237            [238                MyTaskSet.dont_exclude_twice,239                MyTaskSet.dont_exclude_twice,240                MyTaskSet.dont_exclude_3_times,241                MyTaskSet.dont_exclude_3_times,242                MyTaskSet.dont_exclude_3_times,243                MyTaskSet.exclude_4_times,244                MyTaskSet.exclude_4_times,245                MyTaskSet.exclude_4_times,246                MyTaskSet.exclude_4_times,247                MyTaskSet.exclude_5_times,248                MyTaskSet.exclude_5_times,249                MyTaskSet.exclude_5_times,250                MyTaskSet.exclude_5_times,251                MyTaskSet.exclude_5_times,252            ],253        )254        filter_tasks_by_tags(MyTaskSet, exclude_tags=set(["excluded"]))255        self.assertListEqual(256            MyTaskSet.tasks,257            [258                MyTaskSet.dont_exclude_twice,259                MyTaskSet.dont_exclude_twice,260                MyTaskSet.dont_exclude_3_times,261                MyTaskSet.dont_exclude_3_times,262                MyTaskSet.dont_exclude_3_times,263            ],264        )265    def test_tagged_tasks_shared_across_tasksets(self):266        @tag("tagged")267        def shared_task():268            pass269        def untagged_shared_task():270            pass271        @tag("tagged")272        class SharedTaskSet(TaskSet):273            @task274            def inner_task(self):275                pass276        class IncludeTaskSet(TaskSet):277            tasks = [shared_task, untagged_shared_task, SharedTaskSet]278        class ExcludeTaskSet(TaskSet):279            tasks = [shared_task, untagged_shared_task, SharedTaskSet]280        filter_tasks_by_tags(IncludeTaskSet, tags=set(["tagged"]))281        self.assertListEqual(IncludeTaskSet.tasks, [shared_task, SharedTaskSet])282        self.assertListEqual(IncludeTaskSet.tasks[1].tasks, [SharedTaskSet.inner_task])283        filter_tasks_by_tags(ExcludeTaskSet, exclude_tags=set(["tagged"]))284        self.assertListEqual(ExcludeTaskSet.tasks, [untagged_shared_task])285    def test_include_tags_under_user(self):286        class MyUser(User):287            @tag("include this")288            @task289            def included(self):290                pass291            @tag("dont include this")292            @task293            def not_included(self):294                pass295            @task296            def dont_include_this_either(self):297                pass298        filter_tasks_by_tags(MyUser, tags=set(["include this"]))299        self.assertListEqual(MyUser.tasks, [MyUser.included])300    def test_exclude_tags_under_user(self):301        class MyUser(User):302            @tag("exclude this")303            @task304            def excluded(self):305                pass306            @tag("dont exclude this")307            @task308            def not_excluded(self):309                pass310            @task311            def dont_exclude_this_either(self):312                pass313        filter_tasks_by_tags(MyUser, exclude_tags=set(["exclude this"]))314        self.assertListEqual(MyUser.tasks, [MyUser.not_excluded, MyUser.dont_exclude_this_either])315    def test_env_include_tags(self):316        class MyTaskSet(TaskSet):317            @tag("include this")318            @task319            def included(self):320                pass321            @tag("dont include this")322            @task323            def not_included(self):324                pass325            @task326            def dont_include_this_either(self):327                pass328        class MyUser(User):329            tasks = [MyTaskSet]330        env = Environment(user_classes=[MyUser], tags=["include this"])331        env._filter_tasks_by_tags()332        self.assertListEqual(MyUser.tasks, [MyTaskSet])333        self.assertListEqual(MyUser.tasks[0].tasks, [MyTaskSet.included])334    def test_env_exclude_tags(self):335        class MyTaskSet(User):336            @tag("exclude this")337            @task338            def excluded(self):339                pass340            @tag("dont exclude this")341            @task342            def not_excluded(self):343                pass344            @task345            def dont_exclude_this_either(self):346                pass347        class MyUser(User):348            tasks = [MyTaskSet]349        env = Environment(user_classes=[MyUser], exclude_tags=["exclude this"])350        env._filter_tasks_by_tags()351        self.assertListEqual(MyUser.tasks, [MyTaskSet])...30.07.py
Source:30.07.py  
1# words = input()2# while words != 'Stop':3#     print(words)4#     words = input()5#6#7#8# username = input()9# password = input()10# entered_password = input()11#12# while entered_password != password:13#     entered_password = input()14#15# print(f'Welcome {username}!')16#17#18#19#20# number = int(input())21# sum_num = 022#23# while sum_num < number:24#     new_number = int(input())25#     sum_num += new_number26#27# print(sum_num)28#29#30#31#32# number = int(input())33# sequential_number = 134#35# while sequential_number <= number:36#     print(sequential_number)37#     sequential_number = sequential_number * 2 + 138#39#40#41#42#43#44#45# inputting = input()46# total_moneys = 047#48# while inputting != 'NoMoreMoney':49#     number_sum = float(inputting)50#51#     if number_sum < 0:52#         print('Invalid operation!')53#         break54#     print(f'Increase: {number_sum:.2f}')55#56#     total_moneys += number_sum57#58#     inputting = input()59#60# print(f'Total: {total_moneys:.2f}')61#62#63#64#65# import sys66# command = input()67# max_number = -sys.maxsize68#69# while command != 'Stop':70#     command1 = int(command)71#72#     if command1 > max_number:73#         max_number = command174#75#     command = input()76#77# print(max_number)78#79#80#81#82# import sys83# command = input()84# min_number = sys.maxsize85#86# while command != 'Stop':87#     command1 = int(command)88#89#     if command1 < min_number:90#         min_number = command191#92#     command = input()93#94# print(min_number)95#96#97#98#99#100# name = input()101# not_excluded = True102# suspended = 0103# year = 1104# avg_grade = 0105# grade = 0106#107# while not_excluded:108#     grade = float(input())109#     if grade >= 4:110#         year += 1111#         avg_grade += grade112#     elif grade < 4:113#         suspended += 1114#115#     if suspended >= 2:116#         print(f'{name} has been excluded at {year} grade')117#         not_excluded = False118#119#     if year == 12:120#         avg_grade /= year121#         break122# if not_excluded == True and year == 12:123#     print(f'{name} graduated. Average grade: {avg_grade:.2f}')124#125#126#127#128#129# name = input()130# not_excluded = True131# suspended = 0132# year = 1133# avg_grade = 0134# grade = 0135#136# while not_excluded:137#     grade = float(input())138#     if grade >= 4:139#         year += 1140#         avg_grade += grade141#     elif grade < 4:142#         suspended += 1143#144#     if suspended >= 2:145#         not_excluded = False146#147#     if year == 13:148#         avg_grade /= 12149#         break150# if not_excluded:151#     print(f'{name} graduated. Average grade: {avg_grade:.2f}')152# else:...shibanatazadacha.py
Source:shibanatazadacha.py  
1name = input()2not_excluded = True3suspended = 04year = 15avg_grade = 06grade = 07while not_excluded:8    grade = float(input())9    if grade >= 4:10        year += 111        avg_grade += grade12    elif grade < 4:13        suspended += 114    if suspended >= 2:15        not_excluded = False16    if year == 13:17        avg_grade /= 1218        break19if not_excluded:20    print(f'{name} graduated. Average grade: {avg_grade:.2f}')21else:22    print(f'{name} has been excluded at {year} grade')...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!!
