From a5c0940208c358104645c510c02909a54947f556 Mon Sep 17 00:00:00 2001 From: gfyoung Date: Mon, 22 Jan 2018 02:19:18 -0800 Subject: [PATCH 1/2] 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. --- ci/lint.sh | 8 ++++++++ 1 file changed, 8 insertions(+) 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 From 09097c8153c1efb360998f9056f85bd979bd30d8 Mon Sep 17 00:00:00 2001 From: gfyoung Date: Mon, 22 Jan 2018 09:05:46 -0800 Subject: [PATCH 2/2] MAINT: Patch lint error with pytest.warns The lint correctly fails on this line. --- pandas/tests/series/test_timeseries.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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]