From 38fe3591518afd5b7cde31c12f94cc7429f102ce Mon Sep 17 00:00:00 2001 From: debugtalk Date: Tue, 25 Jun 2019 20:53:25 +0800 Subject: [PATCH] fix: ImportError when locustio is not installed --- CHANGELOG.md | 1 + httprunner/cli.py | 12 +++++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4ab4ca1..1a6aa377 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ **Bugfixes** - fix extend with testcase reference in format version 2 +- fix ImportError when locustio is not installed ## 2.2.0 (2019-06-24) diff --git a/httprunner/cli.py b/httprunner/cli.py index 888f6a97..2bafe0c8 100644 --- a/httprunner/cli.py +++ b/httprunner/cli.py @@ -91,14 +91,12 @@ def main_hrun(): def main_locust(): """ 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 sys - from httprunner import logger - try: + # monkey patch ssl at beginning to avoid RecursionError when running locust. + from gevent import monkey; monkey.patch_ssl() + import multiprocessing + import sys + from httprunner import logger from httprunner import locusts except ImportError: msg = "Locust is not installed, install first and try again.\n"