()
| 1969 | reason="uses deprecated thread-unsafe warnings control utilities" |
| 1970 | ) |
| 1971 | def test_suppress_warnings_forwarding(): |
| 1972 | # NOTE(seberg): We test for the DeprecationWarning mainly because on |
| 1973 | # free-threaded Python an "ignore" warning filters seem to collide with |
| 1974 | # parts of what `suppress_warnings` does (if used more than once?). |
| 1975 | with pytest.warns( |
| 1976 | DeprecationWarning, |
| 1977 | match="suppression and assertion utilities are deprecated"): |
| 1978 | def warn_other_module(): |
| 1979 | # Apply along axis is implemented in python; stacklevel=2 means |
| 1980 | # we end up inside its module, not ours. |
| 1981 | def warn(arr): |
| 1982 | warnings.warn("Some warning", stacklevel=2) |
| 1983 | return arr |
| 1984 | np.apply_along_axis(warn, 0, [0]) |
| 1985 | |
| 1986 | with suppress_warnings() as sup: |
| 1987 | sup.record() |
| 1988 | with suppress_warnings("always"): |
| 1989 | for i in range(2): |
| 1990 | warnings.warn("Some warning") |
| 1991 | |
| 1992 | # includes a DeprecationWarning for suppress_warnings |
| 1993 | assert_equal(len(sup.log), 3) |
| 1994 | |
| 1995 | with suppress_warnings() as sup: |
| 1996 | sup.record() |
| 1997 | with suppress_warnings("location"): |
| 1998 | for i in range(2): |
| 1999 | warnings.warn("Some warning") |
| 2000 | warnings.warn("Some warning") |
| 2001 | |
| 2002 | # includes a DeprecationWarning for suppress_warnings |
| 2003 | assert_equal(len(sup.log), 3) |
| 2004 | |
| 2005 | with suppress_warnings() as sup: |
| 2006 | sup.record() |
| 2007 | with suppress_warnings("module"): |
| 2008 | for i in range(2): |
| 2009 | warnings.warn("Some warning") |
| 2010 | warnings.warn("Some warning") |
| 2011 | warn_other_module() |
| 2012 | |
| 2013 | # includes a DeprecationWarning for suppress_warnings |
| 2014 | assert_equal(len(sup.log), 3) |
| 2015 | |
| 2016 | with suppress_warnings() as sup: |
| 2017 | sup.record() |
| 2018 | with suppress_warnings("once"): |
| 2019 | for i in range(2): |
| 2020 | warnings.warn("Some warning") |
| 2021 | warnings.warn("Some other warning") |
| 2022 | warn_other_module() |
| 2023 | |
| 2024 | # includes a DeprecationWarning for suppress_warnings |
| 2025 | assert_equal(len(sup.log), 3) |
| 2026 | |
| 2027 | |
| 2028 | def test_tempdir(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…