Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions locust/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,8 +821,8 @@ def print_stats_json(stats: RequestStats) -> None:


def save_stats_json(stats: RequestStats, filename: str) -> None:
with open(f"{filename}.json", "w") as _:
json.dumps(stats.serialize_stats(), indent=4)
with open(f"{filename}.json", "w") as file:
json.dump(stats.serialize_stats(), file, indent=4)


def get_stats_summary(stats: RequestStats, current=True) -> list[str]:
Expand Down
3 changes: 3 additions & 0 deletions locust/test/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2108,6 +2108,9 @@ def hello_world(self):
stdout, stderr = proc.communicate()
self.assertNotIn("error: argument --json-file: expected one argument", stderr)
self.assertTrue(os.path.exists(output_filepath))
with open(output_filepath, encoding="utf-8") as file:
[stats] = json.load(file)
self.assertEqual(stats["name"], "/")

if os.path.exists(output_filepath):
os.remove(output_filepath)
Expand Down