Repository: locustio/locust
File: locust/test/test_main.py (Python)

Code before:
                " ".join(
                    [
                        "locust",
                        "-f",
                        mocked.file_path,
                        "--headless",
                        "--run-time",
                        "2s",
                        "-u",
                        "5",
                        "-r",
                        "10",
                        "User2",
                        "User3",
                    ]
                ),
                stderr=STDOUT,
                stdout=PIPE,
                shell=True,
                text=True,
            )

            output = proc.communicate()[0]
            self.assertNotIn("User1 is running", output)
            self.assertIn("User2 is running", output)
            self.assertIn("User3 is running", output)
            self.assertEqual(0, proc.returncode)

    def test_html_report_option(self):
        html_template = "some_name_{u}_{r}_{t}.html"
        expected_filename = "some_name_11_5_2.html"

        with mock_locustfile() as mocked:

            # Get system temp directory
            temp_dir = tempfile.gettempdir()

            # Define the input filename as well as the resulting filename within the temp directory
            html_report_file_path = os.path.join(temp_dir, html_template)
            output_html_report_file_path = os.path.join(temp_dir, expected_filename)

            try:
                output = subprocess.check_output(
                    [
                        "locust",
                        "-f",
                        mocked.file_path,
                        "--host",
                        "https://test.com/",
                        "--run-time",
                        "2s",

Review comment (suggestion):
This test still tests everything it tested before. It now additionally adds testing for the html file name. In order to do this, I use temp storage so that the file can get generated. 

Code after:
                        "-f",
                        mocked.file_path,
                        "--headless",
                        "--run-time",
                        "2s",
                        "-u",
                        "5",
                        "-r",
                        "10",
                        "User2",
                        "User3",
                    ]
                ),
                stderr=STDOUT,
                stdout=PIPE,
                shell=True,
                text=True,
            )

            output = proc.communicate()[0]
            self.assertNotIn("User1 is running", output)
            self.assertIn("User2 is running", output)
            self.assertIn("User3 is running", output)
            self.assertEqual(0, proc.returncode)

    def test_html_report_option(self):
        html_template = "some_name_{u}_{r}_{t}.html"
        expected_filename = "some_name_11_5_2.html"

        with mock_locustfile() as mocked:
            # Get system temp directory
            temp_dir = tempfile.gettempdir()

            # Define the input filename as well as the resulting filename within the temp directory
            html_report_file_path = os.path.join(temp_dir, html_template)
            output_html_report_file_path = os.path.join(temp_dir, expected_filename)

            try:
                output = subprocess.check_output(
                    [
                        "locust",
                        "-f",
                        mocked.file_path,
                        "--host",
                        "https://test.com/",
                        "--run-time",
                        "2s",
                        "--headless",
                        "--exit-code-on-error",
                        "0",
                        "-u",