Skip to content

Commit 71fcdb4

Browse files
committed
Skip tests on network error
1 parent 34b55ce commit 71fcdb4

File tree

1 file changed

+38
-31
lines changed

1 file changed

+38
-31
lines changed

pandas/io/tests/test_google.py

+38-31
Original file line numberDiff line numberDiff line change
@@ -45,37 +45,44 @@ def test_get_quote(self):
4545

4646
@network
4747
def test_get_data(self):
48-
import numpy as np
49-
df = web.get_data_google('GOOG')
50-
print(df.Volume.ix['OCT-08-2010'])
51-
assert df.Volume.ix['OCT-08-2010'] == 2863473
52-
53-
sl = ['AAPL', 'AMZN', 'GOOG']
54-
pan = web.get_data_google(sl, '2012')
55-
ts = pan.Close.GOOG.index[pan.Close.AAPL > pan.Close.GOOG]
56-
assert ts[0].dayofyear == 96
57-
58-
pan = web.get_data_google(['GE', 'MSFT', 'INTC'], 'JAN-01-12', 'JAN-31-12')
59-
expected = [19.02, 28.23, 25.39]
60-
result = pan.Close.ix['01-18-12'][['GE', 'MSFT', 'INTC']].tolist()
61-
assert result == expected
62-
63-
# sanity checking
64-
t= np.array(result)
65-
assert np.issubdtype(t.dtype, np.floating)
66-
assert t.shape == (3,)
67-
68-
expected = [[ 18.99, 28.4 , 25.18],
69-
[ 18.58, 28.31, 25.13],
70-
[ 19.03, 28.16, 25.52],
71-
[ 18.81, 28.82, 25.87]]
72-
result = pan.Open.ix['Jan-15-12':'Jan-20-12'][['GE', 'MSFT', 'INTC']].values
73-
assert (result == expected).all()
74-
75-
# sanity checking
76-
t= np.array(pan)
77-
assert np.issubdtype(t.dtype, np.floating)
78-
48+
try:
49+
import numpy as np
50+
df = web.get_data_google('GOOG')
51+
print(df.Volume.ix['OCT-08-2010'])
52+
assert df.Volume.ix['OCT-08-2010'] == 2863473
53+
54+
sl = ['AAPL', 'AMZN', 'GOOG']
55+
pan = web.get_data_google(sl, '2012')
56+
ts = pan.Close.GOOG.index[pan.Close.AAPL > pan.Close.GOOG]
57+
assert ts[0].dayofyear == 96
58+
59+
pan = web.get_data_google(['GE', 'MSFT', 'INTC'], 'JAN-01-12', 'JAN-31-12')
60+
expected = [19.02, 28.23, 25.39]
61+
result = pan.Close.ix['01-18-12'][['GE', 'MSFT', 'INTC']].tolist()
62+
assert result == expected
63+
64+
# sanity checking
65+
t= np.array(result)
66+
assert np.issubdtype(t.dtype, np.floating)
67+
assert t.shape == (3,)
68+
69+
expected = [[ 18.99, 28.4 , 25.18],
70+
[ 18.58, 28.31, 25.13],
71+
[ 19.03, 28.16, 25.52],
72+
[ 18.81, 28.82, 25.87]]
73+
result = pan.Open.ix['Jan-15-12':'Jan-20-12'][['GE', 'MSFT', 'INTC']].values
74+
assert (result == expected).all()
75+
76+
# sanity checking
77+
t= np.array(pan)
78+
assert np.issubdtype(t.dtype, np.floating)
79+
except IOError:
80+
try:
81+
urllib2.urlopen('http://www.google.com')
82+
except IOError:
83+
raise nose.SkipTest
84+
else:
85+
raise
7986

8087
if __name__ == '__main__':
8188
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],

0 commit comments

Comments
 (0)