def test_conftest_warning_captured(self, pytester: Pytester) -> None:
        """Warnings raised during importing of conftest.py files is captured (#2891)."""
        pytester.makeconftest(
            """
            import warnings
            warnings.warn(UserWarning("my custom warning"))
            """
        )
        result = pytester.runpytest()
        result.stdout.fnmatch_lines(
            ["conftest.py:2", "*UserWarning: my custom warning*"]
        )
Warnings raised during importing of conftest.py files is captured (#2891).
testing/test_warnings.py