Bug description
parse_options() in locust/argument_parser.py signals its own deprecation with a bare print() call instead of warnings.warn(msg, DeprecationWarning, stacklevel=2).
Consequences
- The warning goes to stdout instead of stderr, breaking scripts that capture stdout.
- Python's
-W ignore::DeprecationWarning flag cannot suppress this warning.
warnings.catch_warnings(record=True) (used in test suites) never sees it.
- Every call prints the warning again; Python's once-per-call-site deduplication does not apply.
- The caller's file/line does not appear in the warning text.
Reproduction
import warnings
from locust.argument_parser import parse_options
with warnings.catch_warnings(record=True) as caught:
warnings.simplefilter('always')
parse_options(args=['-f', 'locustfile.py'])
# Expected: len(caught) == 1 and caught[0].category is DeprecationWarning
# Actual: len(caught) == 0 (warning was print()-ed to stdout instead)
print(len(caught)) # prints 0
Expected behaviour
parse_options() should call warnings.warn(msg, DeprecationWarning, stacklevel=2) so the warning participates in Python's standard warning system, can be suppressed with -W, and is caught by catch_warnings().
Locust version
master (d473f65)
Bug description
parse_options()inlocust/argument_parser.pysignals its own deprecation with a bareprint()call instead ofwarnings.warn(msg, DeprecationWarning, stacklevel=2).Consequences
-W ignore::DeprecationWarningflag cannot suppress this warning.warnings.catch_warnings(record=True)(used in test suites) never sees it.Reproduction
Expected behaviour
parse_options()should callwarnings.warn(msg, DeprecationWarning, stacklevel=2)so the warning participates in Python's standard warning system, can be suppressed with-W, and is caught bycatch_warnings().Locust version
master (d473f65)