Пример #1
0
 def test_post_processing_returns_an_indented_string_given_an_indentation(
         self):
     a_request = MagicMock(spec_set=Request)
     a_request.method = HttpMethod.GET
     task = Task("some_task", a_request)
     new_post_processings = (*task.locust_postprocessing,
                             "def some_function():")
     task = task._replace(locust_postprocessing=new_post_processings)
     action = task.as_locust_action(indentation=2)
     assert "  def some_function():" in action
Пример #2
0
 def test_it_respects_sub_indentation_levels(self):
     a_request = MagicMock(spec_set=Request)
     a_request.method = HttpMethod.GET
     task = Task("some_task", a_request)
     new_pre_processings = (
         *task.locust_preprocessing,
         "\n  def function():\n   if True:\n    print(True)",
     )
     task = task._replace(locust_preprocessing=new_pre_processings)
     action = task.as_locust_action(indentation=1)
     assert action.startswith(
         " \n def function():\n  if True:\n   print(True)")
Пример #3
0
 def test_it_applies_indentation_to_all_pre_processings(self):
     a_request = MagicMock(spec_set=Request)
     a_request.method = HttpMethod.GET
     task = Task("some_task", a_request)
     new_pre_processings = (
         *task.locust_preprocessing,
         "def some_function():",
         "def some_other_function():",
     )
     task = task._replace(locust_preprocessing=new_pre_processings)
     action = task.as_locust_action(indentation=2)
     assert action.startswith(
         "  def some_function():\n\n  def some_other_function():")