mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-07 08:27:35 +08:00
change httprunner api HttpRunner location to avoid monkey patch
This commit is contained in:
@@ -1,11 +0,0 @@
|
|||||||
# encoding: utf-8
|
|
||||||
|
|
||||||
try:
|
|
||||||
# monkey patch ssl at beginning to avoid RecursionError when running locust.
|
|
||||||
from gevent import monkey
|
|
||||||
if not monkey.is_module_patched('ssl'):
|
|
||||||
monkey.patch_ssl()
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
from httprunner.api import HttpRunner
|
|
||||||
|
|||||||
@@ -90,6 +90,9 @@ def main_hrun():
|
|||||||
def main_locust():
|
def main_locust():
|
||||||
""" Performance test with locust: parse command line options and run commands.
|
""" Performance test with locust: parse command line options and run commands.
|
||||||
"""
|
"""
|
||||||
|
# monkey patch ssl at beginning to avoid RecursionError when running locust.
|
||||||
|
from gevent import monkey; monkey.patch_ssl()
|
||||||
|
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
import sys
|
import sys
|
||||||
from httprunner import logger
|
from httprunner import logger
|
||||||
|
|||||||
+3
-2
@@ -3,7 +3,8 @@ import shutil
|
|||||||
import time
|
import time
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from httprunner import HttpRunner, api, loader, parser
|
from httprunner import loader, parser
|
||||||
|
from httprunner.api import HttpRunner, prepare_locust_tests
|
||||||
from locust import HttpLocust
|
from locust import HttpLocust
|
||||||
from tests.api_server import HTTPBIN_SERVER
|
from tests.api_server import HTTPBIN_SERVER
|
||||||
from tests.base import ApiServerUnittest
|
from tests.base import ApiServerUnittest
|
||||||
@@ -570,7 +571,7 @@ class TestLocust(unittest.TestCase):
|
|||||||
def test_prepare_locust_tests(self):
|
def test_prepare_locust_tests(self):
|
||||||
path = os.path.join(
|
path = os.path.join(
|
||||||
os.getcwd(), 'tests/locust_tests/demo_simple_locust.yml')
|
os.getcwd(), 'tests/locust_tests/demo_simple_locust.yml')
|
||||||
locust_tests = api.prepare_locust_tests(path)
|
locust_tests = prepare_locust_tests(path)
|
||||||
self.assertIn("gen_md5", locust_tests["functions"])
|
self.assertIn("gen_md5", locust_tests["functions"])
|
||||||
self.assertEqual(len(locust_tests["tests"]), 10)
|
self.assertEqual(len(locust_tests["tests"]), 10)
|
||||||
self.assertEqual(locust_tests["tests"][0]["name"], "index")
|
self.assertEqual(locust_tests["tests"][0]["name"], "index")
|
||||||
|
|||||||
Reference in New Issue
Block a user