diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index be363c69..6ed7dfa3 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -5,6 +5,7 @@ **Fixed** - fix #826: Windows does not support file name include ":" +- fix #819: maximum recursion error in locusts ## 2.5.1 (2020-01-02) diff --git a/httprunner/__init__.py b/httprunner/__init__.py index 86fe1344..75a512bb 100644 --- a/httprunner/__init__.py +++ b/httprunner/__init__.py @@ -2,15 +2,3 @@ __version__ = "2.5.2" __description__ = "One-stop solution for HTTP(S) testing." __all__ = ["__version__", "__description__"] - -import uuid - -import sentry_sdk - -sentry_sdk.init( - dsn="https://cc6dd86fbe9f4e7fbd95248cfcff114d@sentry.io/1862849", - release="httprunner@{}".format(__version__) -) - -with sentry_sdk.configure_scope() as scope: - scope.set_user({"id": uuid.getnode()}) diff --git a/httprunner/cli.py b/httprunner/cli.py index 0ffb17d6..3d37589c 100644 --- a/httprunner/cli.py +++ b/httprunner/cli.py @@ -2,7 +2,7 @@ import argparse import os import sys -from sentry_sdk import capture_exception +import sentry_sdk from httprunner import __description__, __version__, exceptions from httprunner.api import HttpRunner @@ -11,7 +11,9 @@ from httprunner.loader import load_cases from httprunner.logger import color_print, log_error from httprunner.report import gen_html_report from httprunner.utils import (create_scaffold, get_python2_retire_msg, - prettify_json_file) + prettify_json_file, init_sentry_sdk) + +init_sentry_sdk() def main(): @@ -115,7 +117,7 @@ def main(): except Exception as ex: color_print("!!!!!!!!!! exception stage: {} !!!!!!!!!!".format(runner.exception_stage), "YELLOW") color_print(str(ex), "RED") - capture_exception(ex) + sentry_sdk.capture_exception(ex) err_code = 1 sys.exit(err_code) diff --git a/httprunner/ext/har2case/__init__.py b/httprunner/ext/har2case/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/httprunner/ext/locusts/cli.py b/httprunner/ext/locusts/cli.py index 364ab22f..90a99a39 100644 --- a/httprunner/ext/locusts/cli.py +++ b/httprunner/ext/locusts/cli.py @@ -19,6 +19,9 @@ import os import sys from httprunner import logger +from httprunner.utils import init_sentry_sdk + +init_sentry_sdk() def parse_locustfile(file_path): diff --git a/httprunner/utils.py b/httprunner/utils.py index 67b972e8..53d1e15c 100644 --- a/httprunner/utils.py +++ b/httprunner/utils.py @@ -7,15 +7,28 @@ import itertools import json import os.path import re +import uuid from datetime import datetime -from httprunner import exceptions, logger +import sentry_sdk + +from httprunner import exceptions, logger, __version__ from httprunner.compat import basestring, bytes, is_py2 from httprunner.exceptions import ParamsError absolute_http_url_regexp = re.compile(r"^https?://", re.I) +def init_sentry_sdk(): + sentry_sdk.init( + dsn="https://cc6dd86fbe9f4e7fbd95248cfcff114d@sentry.io/1862849", + release="httprunner@{}".format(__version__) + ) + + with sentry_sdk.configure_scope() as scope: + scope.set_user({"id": uuid.getnode()}) + + def set_os_environ(variables_mapping): """ set variables mapping to os.environ """