Skip to content

Commit

Permalink
Added test for TaskSet's parent attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
heyman committed Dec 20, 2012
1 parent aeda52d commit bf78635
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions locust/test/test_locust_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,33 @@ class MyLocust2(Locust):
except:
raise

def test_parent_attribute(self):
from locust.exception import StopLocust
parents = {}

class SubTaskSet(TaskSet):
def on_start(self):
parents["sub"] = self.parent

@task
class SubSubTaskSet(TaskSet):
def on_start(self):
parents["subsub"] = self.parent
@task
def stop(self):
raise StopLocust()
class RootTaskSet(TaskSet):
tasks = [SubTaskSet]

class MyLocust(Locust):
host = ""
task_set = RootTaskSet

l = MyLocust()
l.run()
self.assertTrue(isinstance(parents["sub"], RootTaskSet))
self.assertTrue(isinstance(parents["subsub"], SubTaskSet))


class TestWebLocustClass(WebserverTestCase):
def test_get_request(self):
Expand Down

0 comments on commit bf78635

Please sign in to comment.