This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 70cefebbd5 Disable `PytestDeprecationWarning` when create 
warnings_recorder (#36759)
70cefebbd5 is described below

commit 70cefebbd5e20989b48386742089ebf747d991c1
Author: Andrey Anshin <[email protected]>
AuthorDate: Sat Jan 13 11:06:19 2024 +0400

    Disable `PytestDeprecationWarning` when create warnings_recorder (#36759)
---
 tests/conftest.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tests/conftest.py b/tests/conftest.py
index 4c4e022aa9..9176ab9628 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -29,7 +29,6 @@ from typing import TYPE_CHECKING
 
 import pytest
 import time_machine
-from _pytest.recwarn import WarningsRecorder
 
 # We should set these before loading _any_ of the rest of airflow so that the
 # unit test mode config is set as early as possible.
@@ -1148,7 +1147,9 @@ def close_all_sqlalchemy_sessions():
 
 captured_warnings: dict[tuple[str, int, type[Warning], str], 
warnings.WarningMessage] = {}
 captured_warnings_count: dict[tuple[str, int, type[Warning], str], int] = {}
-warnings_recorder = WarningsRecorder()
+# By set ``_ispytest=True`` in WarningsRecorder we suppress annoying warnings:
+# PytestDeprecationWarning: A private pytest class or function was used.
+warnings_recorder = pytest.WarningsRecorder(_ispytest=True)
 default_formatwarning = warnings_recorder._module.formatwarning  # type: 
ignore[attr-defined]
 default_showwarning = warnings_recorder._module.showwarning  # type: 
ignore[attr-defined]
 

Reply via email to