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

Code before:
            if tbopt == "long":
                assert "print(6*7)" in s
            else:
                assert "print(6*7)" not in s
            if tbopt != "no":
                assert "--calling--" in s
                assert "IndexError" in s
            else:
                assert "FAILURES" not in s
                assert "--calling--" not in s
                assert "IndexError" not in s

    def test_tb_line_show_capture(self, pytester: Pytester, option) -> None:
        output_to_capture = "help! let me out!"
        pytester.makepyfile(
            f"""
            import pytest
            def test_fail():
                print('{output_to_capture}')
                assert False
            """
        )
        result = pytester.runpytest("--tb=line")
        result.stdout.fnmatch_lines(["*- Captured stdout call -*"])
        s = result.stdout.str()
        assert output_to_capture in s

    def test_tb_crashline(self, pytester: Pytester, option) -> None:
        p = pytester.makepyfile(
            """
            import pytest
            def g():
                raise IndexError
            def test_func1():
                print(6*7)
                g()  # --calling--
            def test_func2():
                assert 0, "hello"
        """
        )
        result = pytester.runpytest("--tb=line")
        bn = p.name
        result.stdout.fnmatch_lines(
            [f"*{bn}:3: IndexError*", f"*{bn}:8: AssertionError: hello*"]
        )
        s = result.stdout.str()
        assert "def test_func2" not in s

    def test_tb_crashline_pytrace_false(self, pytester: Pytester, option) -> None:
        p = pytester.makepyfile(
            """

Review comment (suggestion):
Perhaps just use the same `fnmatch_lines` call?


```suggestion
        result.stdout.fnmatch_lines([
            "*- Captured stdout call -*",
            output_to_capture
        ])
```

If you were having problems with that, I suspect it is the `!` in the `output_to_capture` string. Given it is not important to the test, I suggest just changing the string to `HELPLETMEOUT` or something like this.

Code after:
            if tbopt == "long":
                assert "print(6*7)" in s
            else:
                assert "print(6*7)" not in s
            if tbopt != "no":
                assert "--calling--" in s
                assert "IndexError" in s
            else:
                assert "FAILURES" not in s
                assert "--calling--" not in s
                assert "IndexError" not in s

    def test_tb_line_show_capture(self, pytester: Pytester, option) -> None:
        output_to_capture = "help! let me out!"
        pytester.makepyfile(
            f"""
            import pytest
            def test_fail():
                print('{output_to_capture}')
                assert False
            """
        )
        result = pytester.runpytest("--tb=line")
        result.stdout.fnmatch_lines(["*- Captured stdout call -*", output_to_capture])

    def test_tb_crashline(self, pytester: Pytester, option) -> None:
        p = pytester.makepyfile(
            """
            import pytest
            def g():
                raise IndexError
            def test_func1():
                print(6*7)
                g()  # --calling--
            def test_func2():
                assert 0, "hello"
        """
        )
        result = pytester.runpytest("--tb=line")
        bn = p.name
        result.stdout.fnmatch_lines(
            [f"*{bn}:3: IndexError*", f"*{bn}:8: AssertionError: hello*"]
        )
        s = result.stdout.str()
        assert "def test_func2" not in s

    def test_tb_crashline_pytrace_false(self, pytester: Pytester, option) -> None:
        p = pytester.makepyfile(
            """
            import pytest
            def test_func1():