diff --git a/httprunner/__init__.py b/httprunner/__init__.py index 7fbb6af4..ef770dc2 100644 --- a/httprunner/__init__.py +++ b/httprunner/__init__.py @@ -1,4 +1,4 @@ -__version__ = "2.2.6" +__version__ = "2.2.7" __description__ = "One-stop solution for HTTP(S) testing." __all__ = ["__version__", "__description__"] diff --git a/httprunner/__main__.py b/httprunner/__main__.py new file mode 100644 index 00000000..1f1c95e0 --- /dev/null +++ b/httprunner/__main__.py @@ -0,0 +1,27 @@ +import os +import sys + +from httprunner.cli import main_hrun, main_locust + +if __name__ == "__main__": + """ debugging mode + """ + if len(sys.argv) == 0: + sys.exit(1) + + sys.path.insert(0, os.getcwd()) + cmd = sys.argv.pop(1) + + if cmd in ["hrun", "httprunner", "ate"]: + main_hrun() + elif cmd in ["locust", "locusts"]: + main_locust() + else: + from httprunner.logger import color_print + color_print("Miss debugging type.", "RED") + example = "\n".join([ + "e.g.", + "python -m httprunner hrun /path/to/testcase_file", + "python -m httprunner locusts -f /path/to/testcase_file" + ]) + color_print(example, "yellow") diff --git a/httprunner/cli.py b/httprunner/cli.py index 8bd7b553..67555da7 100644 --- a/httprunner/cli.py +++ b/httprunner/cli.py @@ -186,30 +186,3 @@ def main_locust(): locusts.run_locusts_with_processes(sys.argv, processes_count) else: locusts.start_locust_main() - - -if __name__ == "__main__": - """ debugging mode - """ - import sys - import os - - if len(sys.argv) == 0: - exit(0) - - sys.path.insert(0, os.getcwd()) - cmd = sys.argv.pop(1) - - if cmd in ["hrun", "httprunner", "ate"]: - main_hrun() - elif cmd in ["locust", "locusts"]: - main_locust() - else: - from httprunner.logger import color_print - color_print("Miss debugging type.", "RED") - example = "\n".join([ - "e.g.", - "python -m httprunner.cli hrun /path/to/testcase_file", - "python -m httprunner.cli locusts -f /path/to/testcase_file" - ]) - color_print(example, "yellow")