From d409eaf22f0aa1cf4088ebbbe0b1ab8b3917973b Mon Sep 17 00:00:00 2001 From: gfyoung Date: Mon, 22 Jan 2018 15:59:55 -0800 Subject: [PATCH] MAINT: Remove pytest.warns in tests (#19341) * MAINT: Check for pytest.warns in tests Per discussion in gh-18258, we are prohibiting its use in tests, at least for the time being. * MAINT: Patch lint error with pytest.warns The lint correctly fails on this line. --- ci/lint.sh | 8 ++++++++ pandas/tests/series/test_timeseries.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ci/lint.sh b/ci/lint.sh index a96e0961304e7..98b33c0803d90 100755 --- a/ci/lint.sh +++ b/ci/lint.sh @@ -89,6 +89,14 @@ if [ "$LINT" ]; then if [ $? = "0" ]; then RET=1 fi + + # Check for pytest.warns + grep -r -E --include '*.py' 'pytest\.warns' pandas/tests/ + + if [ $? = "0" ]; then + RET=1 + fi + echo "Check for invalid testing DONE" # Check for imports from pandas.core.common instead diff --git a/pandas/tests/series/test_timeseries.py b/pandas/tests/series/test_timeseries.py index b9c95c372ab9e..7be801629e387 100644 --- a/pandas/tests/series/test_timeseries.py +++ b/pandas/tests/series/test_timeseries.py @@ -937,7 +937,7 @@ def test_from_M8_structured(self): assert isinstance(s[0], Timestamp) assert s[0] == dates[0][0] - with pytest.warns(FutureWarning): + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): s = Series.from_array(arr['Date'], Index([0])) assert s[0] == dates[0][0]