Skip to content

Commit

Permalink
Merge pull request #1329 from locustio/cleanup-(step-one-of-fixing-#1328
Browse files Browse the repository at this point in the history
)

Stop exposing exceptions on locust module, remove old wait api (step 1 of fixing #1328)
  • Loading branch information
cyberw authored Apr 15, 2020
2 parents 6524c2f + e7e4f32 commit 47faf32
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 138 deletions.
1 change: 0 additions & 1 deletion locust/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from .core import HttpLocust, Locust, TaskSet, task
from .event import Events
from .exception import InterruptTaskSet, ResponseError, RescheduleTaskImmediately
from .sequential_taskset import SequentialTaskSet
from .wait_time import between, constant, constant_pacing

Expand Down
7 changes: 1 addition & 6 deletions locust/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,7 @@ class ForumPage(TaskSet):
instantiated. Useful for nested TaskSet classes.
"""

def __init__(self, parent):
# check if deprecated wait API is used
deprecation.check_for_deprecated_wait_api(self)

def __init__(self, parent):
self._task_queue = []
self._time_start = time()

Expand Down Expand Up @@ -465,8 +462,6 @@ class ForumPage(TaskSet):

def __init__(self, environment):
super(Locust, self).__init__()
# check if deprecated wait API is used
deprecation.check_for_deprecated_wait_api(self)
self.environment = environment

def on_start(self):
Expand Down
2 changes: 1 addition & 1 deletion locust/test/test_locust_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from gevent import sleep
from gevent.pool import Group

from locust import InterruptTaskSet, ResponseError
from locust.exception import InterruptTaskSet, ResponseError
from locust.core import HttpLocust, Locust, TaskSet, task
from locust.env import Environment
from locust.exception import (CatchResponseError, LocustError, RescheduleTask,
Expand Down
106 changes: 0 additions & 106 deletions locust/test/test_old_wait_api.py

This file was deleted.

24 changes: 0 additions & 24 deletions locust/util/deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,6 @@
warnings.filterwarnings('always', category=DeprecationWarning, module="locust")


def check_for_deprecated_wait_api(locust_or_taskset):
# check if deprecated wait API is used
if locust_or_taskset.wait_function:
warnings.warn("Usage of wait_function is deprecated since version 0.13. Declare a %s.wait_time method instead "
"(should return seconds and not milliseconds)" % type(locust_or_taskset).__name__, DeprecationWarning)
from locust.core import TaskSet
if not locust_or_taskset.wait_time or locust_or_taskset.wait_time.__func__ == TaskSet.wait_time:
# If wait_function has been declared, and custom wait_time has NOT been declared,
# we'll add a wait_time function that just calls wait_function and divides the
# returned value by 1000.0
locust_or_taskset.wait_time = lambda: locust_or_taskset.wait_function() / 1000.0
if locust_or_taskset.min_wait is not None and locust_or_taskset.max_wait is not None:
def format_min_max_wait(i):
float_value = i / 1000.0
if float_value == int(float_value):
return "%i" % int(float_value)
else:
return "%.3f" % float_value
warnings.warn("Usage of min_wait and max_wait is deprecated since version 0.13. Instead use: wait_time = between(%s, %s)" % (
format_min_max_wait(locust_or_taskset.min_wait),
format_min_max_wait(locust_or_taskset.max_wait),
), DeprecationWarning)


def check_for_deprecated_task_set_attribute(class_dict):
from locust.core import TaskSet
if "task_set" in class_dict:
Expand Down

0 comments on commit 47faf32

Please sign in to comment.