Skip to content

Commit 61cd97a

Browse files
committed
TST: fix some warnings filters
1 parent 4a4292b commit 61cd97a

File tree

8 files changed

+29
-31
lines changed

8 files changed

+29
-31
lines changed

pandas/io/ga.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@
44
3. Goto APIs and register for OAuth2.0 for installed applications
55
4. Download JSON secret file and move into same directory as this file
66
"""
7-
8-
# GH11038
9-
import warnings
10-
warnings.warn("The pandas.io.ga module is deprecated and will be "
11-
"removed in a future version.",
12-
FutureWarning, stacklevel=2)
13-
147
from datetime import datetime
158
import re
169
from pandas import compat
@@ -27,6 +20,12 @@
2720
from oauth2client.client import AccessTokenRefreshError
2821
from pandas.compat import zip, u
2922

23+
# GH11038
24+
import warnings
25+
warnings.warn("The pandas.io.ga module is deprecated and will be "
26+
"removed in a future version.",
27+
FutureWarning, stacklevel=2)
28+
3029
TYPE_MAP = {u('INTEGER'): int, u('FLOAT'): float, u('TIME'): int}
3130

3231
NO_CALLBACK = auth.OOB_CALLBACK_URN

pandas/io/tests/test_data.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ def test_get_date_ret_index(self):
293293

294294

295295
class TestYahooOptions(tm.TestCase):
296+
296297
@classmethod
297298
def setUpClass(cls):
298299
super(TestYahooOptions, cls).setUpClass()

pandas/io/tests/test_excel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import os
77
from distutils.version import LooseVersion
88

9+
import warnings
910
import operator
1011
import functools
1112
import nose
@@ -1829,7 +1830,6 @@ def test_column_format(self):
18291830
# Applicable to xlsxwriter only.
18301831
_skip_if_no_xlsxwriter()
18311832

1832-
import warnings
18331833
with warnings.catch_warnings():
18341834
# Ignore the openpyxl lxml warning.
18351835
warnings.simplefilter("ignore")

pandas/io/tests/test_ga.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
from datetime import datetime
33

4+
import warnings
45
import nose
56
import pandas as pd
67
from pandas import compat
@@ -13,7 +14,12 @@
1314

1415
try:
1516
import httplib2
16-
import pandas.io.ga as ga
17+
import apiclient
18+
19+
# deprecated
20+
with warnings.catch_warnings(record=True):
21+
import pandas.io.ga as ga
22+
1723
from pandas.io.ga import GAnalytics, read_ga
1824
from pandas.io.auth import AuthenticationConfigError, reset_default_token_store
1925
from pandas.io import auth

pandas/io/tests/test_packers.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -461,20 +461,21 @@ def test_sparse_frame(self):
461461

462462
def test_sparse_panel(self):
463463

464-
items = ['x', 'y', 'z']
465-
p = Panel(dict((i, tm.makeDataFrame().ix[:2, :2]) for i in items))
466-
sp = p.to_sparse()
464+
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
465+
items = ['x', 'y', 'z']
466+
p = Panel(dict((i, tm.makeDataFrame().ix[:2, :2]) for i in items))
467+
sp = p.to_sparse()
467468

468-
self._check_roundtrip(sp, tm.assert_panel_equal,
469-
check_panel_type=True)
469+
self._check_roundtrip(sp, tm.assert_panel_equal,
470+
check_panel_type=True)
470471

471-
sp2 = p.to_sparse(kind='integer')
472-
self._check_roundtrip(sp2, tm.assert_panel_equal,
473-
check_panel_type=True)
472+
sp2 = p.to_sparse(kind='integer')
473+
self._check_roundtrip(sp2, tm.assert_panel_equal,
474+
check_panel_type=True)
474475

475-
sp3 = p.to_sparse(fill_value=0)
476-
self._check_roundtrip(sp3, tm.assert_panel_equal,
477-
check_panel_type=True)
476+
sp3 = p.to_sparse(fill_value=0)
477+
self._check_roundtrip(sp3, tm.assert_panel_equal,
478+
check_panel_type=True)
478479

479480

480481
class TestCompression(TestPackers):

pandas/rpy/tests/test_common.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import numpy as np
77
import unittest
88
import nose
9+
import warnings
910
import pandas.util.testing as tm
1011

1112
try:

pandas/stats/tests/test_moments.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ class TestMoments(Base):
4343

4444
def setUp(self):
4545
self._create_data()
46-
warnings.simplefilter("ignore", category=FutureWarning)
47-
48-
def tearDown(self):
49-
warnings.simplefilter("default", category=FutureWarning)
5046

5147
def test_centered_axis_validation(self):
5248
# ok
@@ -890,7 +886,6 @@ def _create_data(self):
890886

891887
def setUp(self):
892888
self._create_data()
893-
warnings.simplefilter("ignore", category=FutureWarning)
894889

895890
def _test_moments_consistency(self,
896891
min_periods,
@@ -1516,9 +1511,6 @@ def test_rolling_functions_window_non_shrinkage(self):
15161511

15171512
functions = [lambda x: mom.rolling_cov(x, x, pairwise=True, window=10, min_periods=5),
15181513
lambda x: mom.rolling_corr(x, x, pairwise=True, window=10, min_periods=5),
1519-
# rolling_corr_pairwise is depracated, so the following line should be deleted
1520-
# when rolling_corr_pairwise is removed.
1521-
lambda x: mom.rolling_corr_pairwise(x, x, window=10, min_periods=5),
15221514
]
15231515
for f in functions:
15241516
df_result_panel = f(df)
@@ -1585,9 +1577,6 @@ def test_moment_functions_zero_length(self):
15851577
lambda x: mom.expanding_corr(x, x, pairwise=True, min_periods=5),
15861578
lambda x: mom.rolling_cov(x, x, pairwise=True, window=10, min_periods=5),
15871579
lambda x: mom.rolling_corr(x, x, pairwise=True, window=10, min_periods=5),
1588-
# rolling_corr_pairwise is depracated, so the following line should be deleted
1589-
# when rolling_corr_pairwise is removed.
1590-
lambda x: mom.rolling_corr_pairwise(x, x, window=10, min_periods=5),
15911580
]
15921581
for f in functions:
15931582
df1_result_panel = f(df1)

pandas/util/testing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,6 +2020,7 @@ def assert_produces_warning(expected_warning=Warning, filter_level="always",
20202020
warnings.simplefilter(filter_level)
20212021
yield w
20222022
extra_warnings = []
2023+
20232024
for actual_warning in w:
20242025
if (expected_warning and issubclass(actual_warning.category,
20252026
expected_warning)):

0 commit comments

Comments
 (0)