Skip to content

parse_options() emits deprecation warning via print() instead of warnings.warn(DeprecationWarning) #3433

Description

@JSap0914

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions