Skip to content

Commit

Permalink
Improve error message if no locust file can be found.
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberw committed Feb 23, 2022
1 parent 1b9c607 commit d47d7dc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions locust/argument_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def get_empty_argument_parser(add_help=True, default_config_files=DEFAULT_CONFIG
"-f",
"--locustfile",
default="locustfile",
help="Python module file to import, e.g. '../other.py'. Default: locustfile",
help="Python module to import, e.g. '../other_test.py'. Either a .py file or a package directory. Defaults to 'locustfile'",
env_var="LOCUST_LOCUSTFILE",
)
parser.add_argument("--config", is_config_file_arg=True, help="Config file path")
Expand Down Expand Up @@ -137,8 +137,12 @@ def parse_locustfile_option(args=None):
if options.help or options.version:
# if --help or --version is specified we'll call parse_options which will print the help/version message
parse_options(args=args)
if options.locustfile.endswith(".py") or options.locustfile == "locustfile":
note_about_file_endings = ""
else:
note_about_file_endings = "Ensure your file ends with '.py'. "
sys.stderr.write(
"Could not find any locustfile! Ensure file ends in '.py' and see --help for available options.\n"
f"Could not find any locustfile called '{options.locustfile}'. {note_about_file_endings}See --help for available options.\n"
)
sys.exit(1)

Expand Down

0 comments on commit d47d7dc

Please sign in to comment.