How to use dont_include_this_either method in locust

Best Python code snippet using locust

test_tags.py

Source:test_tags.py Github

copy

Full Screen

...67 @task68 def not_included(self):69 pass70 @task71 def dont_include_this_either(self):72 pass73 self.assertListEqual(74 MyTaskSet.tasks, [MyTaskSet.included, MyTaskSet.not_included, MyTaskSet.dont_include_this_either]75 )76 filter_tasks_by_tags(MyTaskSet, tags=set(["include this"]))77 self.assertListEqual(MyTaskSet.tasks, [MyTaskSet.included])78 def test_excluding_tags(self):79 class MyTaskSet(TaskSet):80 @tag("exclude this", "other tag")81 @task82 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")...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run locust automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful