Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
--htmldocuments{u},{r},{t}as being converted to "number of users, spawn rate and runtime respectively", but
process_html_filename()cast every substituted value withint()first:-r/--spawn-rateistype=gt_zero(float)(locust/argument_parser.py:492), so a fractional rate isvalid input and the runner honours it — only the report name truncated it.
-r 0.05,-r 0.2and-r 0.5all produced the sameresults_10_0_5.html, so consecutive runs overwrote each other'sreport, and the name contradicted the flag that was passed.
Fixes #3554.
Change
locust/html.py— keep the integer spelling for whole numbers and spell fractional values aspassed:
{u}and{t}are unchanged in practice:--usersistype=int, andparse_timespan()returnswhole seconds and rejects fractional input (
90.5,0.5sboth raise), so{r}is the only tagwhose option is genuinely a float.
-r 5still parses to5.0and still yieldssome_name_11_5_1.html, which is whattest_main.py::test_html_report_optionalready asserts.locust/test/test_html_filename.py— two cases appended to the existingTestProcessHtmlFilename: the per-value expectation (0.5 -> 0.5,1.5 -> 1.5,2.0 -> 2) andthe collision case that motivated the fix (three distinct rates must not collapse onto one path).
How it was checked
On
masterat35c06fad, Python 3.11.14, Windows:New tests before the change: 2 failed, 4 passed
(
AssertionError: 1 != 3for the collision case;results_10_0.htmlinstead ofresults_10_0.5.html).pytest locust/test/test_html_filename.py -qafter the change: 6 passed.Measured through the real parser (
get_parser().parse_args(...)) intoprocess_html_filename(),which is the same object
locust/main.py:674hands over:-rmaster0.050.05results_10_0_5.htmlresults_10_0.05_5.html0.20.2results_10_0_5.htmlresults_10_0.2_5.html0.50.5results_10_0_5.htmlresults_10_0.5_5.html1.51.5results_10_1_5.htmlresults_10_1.5_5.html55.0some_name_11_5_1.htmlsome_name_11_5_1.htmlruff check locust/: all checks passed;ruff format --checkon both files: already formatted;mypy locust/html.py: no issues;typoson both files: clean (ruff 0.16.8, mypy 1.14.1).pytest locust/test/test_main.py -qon this machine: 50 failed / 19 skipped both with andwithout the change — pre-existing Windows-only failures (
TestProcessraisesTypeError: bytes args is not allowed on Windows), not caused by this diff.AI assistance disclosure
This change was produced by the Qoder AI coding assistant in a scripted session (locust lane). The
RED/GREEN counts, the measured table and the failure names above were copied from actual local
command output, and no human has reviewed the change before submission.