8000 Skip tests on network error by gliptak · Pull Request #3893 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

Skip tests on network error #3893

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 19, 2013
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Split tests into multiple
  • Loading branch information
gliptak committed Jun 16, 2013
commit 6cedd92c52dff0b104b40bfe75ce48f5caed6e57
41 changes: 38 additions & 3 deletions pandas/io/tests/test_google.py
< 10000 td class="blob-code blob-code-context js-file-line"> import pandas.io.data as web
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from pandas.util.testing import (network, assert_series_equal)
from numpy.testing.decorators import slow
import numpy as np

import urllib2

Expand All @@ -24,7 +25,23 @@ def test_google(self):
self.assertEquals(
web.DataReader("F", 'google', start, end)['Close'][-1],
13.68)
except urllib2.URLError:
try:
urllib2.urlopen('http://www.google.com')
except urllib2.URLError:
raise nose.SkipTest
else:
raise

@network
def test_google_non_existent(self):
# asserts that google is minimally working and that it throws
# an excecption when DataReader can't get a 200 response from
# google
start = datetime(2010, 1, 1)
end = datetime(2013, 01, 27)

try:
self.assertRaises(
Exception,
lambda: web.DataReader("NON EXISTENT TICKER", 'google',
Expand All @@ -44,18 +61,36 @@ def test_get_quote(self):
lambda: web.get_quote_google(pd.Series(['GOOG', 'AAPL', 'GOOG'])))

@network
def test_get_data(self):
def test_get_goog_volume(self):
try:
import numpy as np
df = web.get_data_google('GOOG')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for example just wrap this in a try clause like so:

import numpy as np
try:
    df = web.get_data_google('GOOG')
except IOError:
    pass
else:
    print(df.Volume.ix['OCT-08-2010'])
    assert df.Volume.ix['OCT-08-2010'] == 2863473

print(df.Volume.ix['OCT-08-2010'])
assert df.Volume.ix['OCT-08-2010'] == 2863473
except IOError:
try:
urllib2.urlopen('http://www.google.com')
except IOError:
raise nose.SkipTest
else:
raise

@network
def test_get_multi1(self):
try:
sl = ['AAPL', 'AMZN', 'GOOG']
pan = web.get_data_google(sl, '2012')
ts = pan.Close.GOOG.index[pan.Close.AAPL > pan.Close.GOOG]
assert ts[0].dayofyear == 96
except IOError:
try:
urllib2.urlopen('http://www.google.com')
except IOError:
raise nose.SkipTest
else:
raise

@network
def test_get_multi2(self):
try:
pan = web.get_data_google(['GE', 'MSFT', 'INTC'], 'JAN-01-12', 'JAN-31-12')
expected = [19.02, 28.23, 25.39]
result = pan.Close.ix['01-18-12'][['GE', 'MSFT', 'INTC']].tolist()
Expand Down
0