use httprunner/cli.py as debugging entrances

This commit is contained in:
debugtalk
2018-02-22 00:24:10 +08:00
parent 66b6f8d904
commit 345c77125b
11 changed files with 29 additions and 35 deletions
+3 -3
View File
@@ -1,9 +1,9 @@
## Development ## Development
To develop or debug `HttpRunner`, you can install relevant requirements and use `main-hrun.py` or `main-locust.py` as entrances. To develop or debug `HttpRunner`, you can install relevant requirements and use `httprunner/cli.py` as entrances.
```bash ```bash
$ python setup.py install $ python setup.py install
$ python main-hrun -h $ python httprunner/cli.py hrun -h
$ python main-locust -h $ python httprunner/cli.py locust -h
``` ```
+14 -6
View File
@@ -5,15 +5,14 @@ import sys
import unittest import unittest
from collections import OrderedDict from collections import OrderedDict
from httprunner import __version__ as hrun_version
from httprunner import logger
from httprunner.exception import TestcaseNotFound
from httprunner.task import Result, TaskSuite
from httprunner.utils import create_scaffold, print_output, string_type
from pyunitreport import __version__ as pyu_version from pyunitreport import __version__ as pyu_version
from pyunitreport import HTMLTestRunner from pyunitreport import HTMLTestRunner
from . import __version__ as hrun_version
from . import logger
from .exception import TestcaseNotFound
from .task import Result, TaskSuite
from .utils import create_scaffold, print_output, string_type
def run_suite_path(path, mapping=None, runner=None): def run_suite_path(path, mapping=None, runner=None):
""" run suite with YAML/JSON file path """ run suite with YAML/JSON file path
@@ -144,3 +143,12 @@ def main_locust():
locusts.run_locusts_on_cpu_cores(sys.argv, cpu_cores_num_value) locusts.run_locusts_on_cpu_cores(sys.argv, cpu_cores_num_value)
else: else:
locusts.main() locusts.main()
if __name__ == '__main__':
cmd = sys.argv.pop(1)
if cmd == "hrun":
main_hrun()
elif cmd == "locust":
main_locust()
+2 -3
View File
@@ -4,13 +4,12 @@ import time
import requests import requests
import urllib3 import urllib3
from httprunner import logger
from httprunner.exception import ParamsError
from requests import Request, Response from requests import Request, Response
from requests.exceptions import (InvalidSchema, InvalidURL, MissingSchema, from requests.exceptions import (InvalidSchema, InvalidURL, MissingSchema,
RequestException) RequestException)
from . import logger
from .exception import ParamsError
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
absolute_http_url_regexp = re.compile(r"^https?://", re.I) absolute_http_url_regexp = re.compile(r"^https?://", re.I)
+3 -3
View File
@@ -3,10 +3,10 @@ import multiprocessing
import os import os
import sys import sys
from locust.main import main from httprunner.logger import color_print
from httprunner.testcase import load_test_file
from .logger import color_print from locust.main import main
from .testcase import load_test_file
def parse_locustfile(file_path): def parse_locustfile(file_path):
+1 -2
View File
@@ -1,10 +1,9 @@
import re import re
from collections import OrderedDict from collections import OrderedDict
from httprunner import exception, logger, testcase, utils
from requests.structures import CaseInsensitiveDict from requests.structures import CaseInsensitiveDict
from . import exception, logger, testcase, utils
text_extractor_regexp_compile = re.compile(r".*\(.*\).*") text_extractor_regexp_compile = re.compile(r".*\(.*\).*")
+3 -3
View File
@@ -1,8 +1,8 @@
from unittest.case import SkipTest from unittest.case import SkipTest
from . import exception, logger, response, testcase, utils from httprunner import exception, logger, response, testcase, utils
from .client import HttpSession from httprunner.client import HttpSession
from .context import Context from httprunner.context import Context
class Runner(object): class Runner(object):
+1 -1
View File
@@ -1,6 +1,6 @@
import unittest import unittest
from . import exception, logger, runner, testcase, utils from httprunner import exception, logger, runner, testcase, utils
class ApiTestCase(unittest.TestCase): class ApiTestCase(unittest.TestCase):
+1 -2
View File
@@ -8,8 +8,7 @@ import re
from collections import OrderedDict from collections import OrderedDict
import yaml import yaml
from httprunner import exception, logger, utils
from . import exception, logger, utils
variable_regexp = r"\$([\w_]+)" variable_regexp = r"\$([\w_]+)"
function_regexp = r"\$\{([\w_]+\([\$\w_ =,]*\))\}" function_regexp = r"\$\{([\w_]+\([\$\w_ =,]*\))\}"
+1 -2
View File
@@ -9,10 +9,9 @@ import string
import types import types
from collections import OrderedDict from collections import OrderedDict
from httprunner import exception, logger
from requests.structures import CaseInsensitiveDict from requests.structures import CaseInsensitiveDict
from . import exception, logger
try: try:
string_type = basestring string_type = basestring
long_type = long long_type = long
-5
View File
@@ -1,5 +0,0 @@
""" used for debugging
"""
from httprunner.cli import main_hrun
main_hrun()
-5
View File
@@ -1,5 +0,0 @@
""" used for debugging
"""
from httprunner.cli import main_locust
main_locust()