Repository: pytest-dev/pytest
File: testing/acceptance_test.py (Python)

Code before:
        result = pytester.runpytest_inprocess("--durations=10")
        assert result.ret == 0

        result.stdout.fnmatch_lines_random(
            ["*durations*", "*call*test_3*", "*call*test_2*"]
        )

        result.stdout.fnmatch_lines(
            ["(8 durations < 0.005s hidden.  Use -vv to show these durations.)"]
        )

    def test_calls_show_2(self, pytester: Pytester, mock_timing) -> None:
        pytester.makepyfile(self.source)
        result = pytester.runpytest_inprocess("--durations=2")
        assert result.ret == 0

        lines = result.stdout.get_lines_after("*slowest*durations*")
        assert "4 passed" in lines[2]

    def test_calls_showall(self, pytester: Pytester, mock_timing) -> None:
        pytester.makepyfile(self.source)
        result = pytester.runpytest_inprocess("--durations=0")
        assert result.ret == 0
        print(result.stdout)
        TestDurations.check_tests_in_output(result.stdout.lines, "23")

    def test_calls_showall_verbose(self, pytester: Pytester, mock_timing) -> None:
        pytester.makepyfile(self.source)
        result = pytester.runpytest_inprocess("--durations=0", "-vv")
        assert result.ret == 0
        TestDurations.check_tests_in_output(result.stdout.lines, "123")

    def test_calls_showall_durationsmin(self, pytester: Pytester, mock_timing) -> None:
        pytester.makepyfile(self.source)
        result = pytester.runpytest_inprocess("--durations=0", "--durations-min=0.015")
        assert result.ret == 0
        TestDurations.check_tests_in_output(result.stdout.lines, "3")

    def test_calls_showall_durationsmin_verbose(
        self, pytester: Pytester, mock_timing
    ) -> None:
        pytester.makepyfile(self.source)
        result = pytester.runpytest_inprocess(
            "--durations=0", "--durations-min=0.015", "-vv"
        )
        assert result.ret == 0
        TestDurations.check_tests_in_output(result.stdout.lines, "3")

    @staticmethod
    def check_tests_in_output(lines: Sequence[str], expected_test_numbers: str) -> None:
        found_test_numbers = "".join(

Review comment (suggestion):
Not sure what the rationale for this comment is. It was added with `--durations` in 3b9fd3a, 13 years ago. I removed it.

Code after:
        result = pytester.runpytest_inprocess("--durations=10")
        assert result.ret == 0

        result.stdout.fnmatch_lines_random(
            ["*durations*", "*call*test_3*", "*call*test_2*"]
        )

        result.stdout.fnmatch_lines(
            ["(8 durations < 0.005s hidden.  Use -vv to show these durations.)"]
        )

    def test_calls_show_2(self, pytester: Pytester, mock_timing) -> None:
        pytester.makepyfile(self.source)
        result = pytester.runpytest_inprocess("--durations=2")
        assert result.ret == 0

        lines = result.stdout.get_lines_after("*slowest*durations*")
        assert "4 passed" in lines[2]

    def test_calls_showall(self, pytester: Pytester, mock_timing) -> None:
        pytester.makepyfile(self.source)
        result = pytester.runpytest_inprocess("--durations=0")
        assert result.ret == 0
        TestDurations.check_tests_in_output(result.stdout.lines, 2, 3)

    def test_calls_showall_verbose(self, pytester: Pytester, mock_timing) -> None:
        pytester.makepyfile(self.source)
        result = pytester.runpytest_inprocess("--durations=0", "-vv")
        assert result.ret == 0
        TestDurations.check_tests_in_output(result.stdout.lines, 1, 2, 3)

    def test_calls_showall_durationsmin(self, pytester: Pytester, mock_timing) -> None:
        pytester.makepyfile(self.source)
        result = pytester.runpytest_inprocess("--durations=0", "--durations-min=0.015")
        assert result.ret == 0
        TestDurations.check_tests_in_output(result.stdout.lines, 3)

    def test_calls_showall_durationsmin_verbose(
        self, pytester: Pytester, mock_timing
    ) -> None:
        pytester.makepyfile(self.source)
        result = pytester.runpytest_inprocess(
            "--durations=0", "--durations-min=0.015", "-vv"
        )
        assert result.ret == 0
        TestDurations.check_tests_in_output(result.stdout.lines, 3)

    @staticmethod
    def check_tests_in_output(
        lines: Sequence[str], *expected_test_numbers: int, number_of_tests: int = 3
    ) -> None: