99import numpy as np
1010import pandas as pd
1111from pandas import DataFrame , Timestamp
12- from pandas .util .testing import (assert_frame_equal , assert_series_equal ,
13- network )
12+ from pandas .util .testing import assert_frame_equal , assert_series_equal
1413try :
1514 from pandas .util .testing import assert_produces_warning
1615except ImportError :
@@ -59,7 +58,6 @@ def tearDownClass(cls):
5958 super (TestGoogle , cls ).tearDownClass ()
6059 del cls .locales
6160
62- @network
6361 def test_google (self ):
6462 # asserts that google is minimally working and that it throws
6563 # an exception when DataReader can't get a 200 response from
@@ -75,19 +73,16 @@ def test_google(self):
7573 self .assertRaises (Exception , web .DataReader , "NON EXISTENT TICKER" ,
7674 'google' , start , end )
7775
78- @network
7976 def test_get_quote_fails (self ):
8077 self .assertRaises (NotImplementedError , web .get_quote_google ,
8178 pd .Series (['GOOG' , 'AAPL' , 'GOOG' ]))
8279
83- @network
8480 def test_get_goog_volume (self ):
8581 for locale in self .locales :
8682 with tm .set_locale (locale ):
8783 df = web .get_data_google ('GOOG' ).sort_index ()
8884 self .assertEqual (df .Volume .ix ['OCT-08-2010' ], 2863473 )
8985
90- @network
9186 def test_get_multi1 (self ):
9287 for locale in self .locales :
9388 sl = ['AAPL' , 'AMZN' , 'GOOG' ]
@@ -100,13 +95,11 @@ def test_get_multi1(self):
10095 else :
10196 self .assertRaises (AttributeError , lambda : pan .Close )
10297
103- @network
10498 def test_get_multi_invalid (self ):
10599 sl = ['AAPL' , 'AMZN' , 'INVALID' ]
106100 pan = web .get_data_google (sl , '2012' )
107101 self .assertIn ('INVALID' , pan .minor_axis )
108102
109- @network
110103 def test_get_multi2 (self ):
111104 with warnings .catch_warnings (record = True ) as w :
112105 for locale in self .locales :
@@ -138,7 +131,6 @@ def setUpClass(cls):
138131 super (TestYahoo , cls ).setUpClass ()
139132 _skip_if_no_lxml ()
140133
141- @network
142134 def test_yahoo (self ):
143135 # asserts that yahoo is minimally working and that it throws
144136 # an exception when DataReader can't get a 200 response from
@@ -149,42 +141,35 @@ def test_yahoo(self):
149141 self .assertEqual (web .DataReader ("F" , 'yahoo' , start , end )['Close' ][- 1 ],
150142 13.68 )
151143
152- @network
153144 def test_yahoo_fails (self ):
154145 start = datetime (2010 , 1 , 1 )
155146 end = datetime (2013 , 1 , 27 )
156147 self .assertRaises (Exception , web .DataReader , "NON EXISTENT TICKER" ,
157148 'yahoo' , start , end )
158149
159- @network
160150 def test_get_quote_series (self ):
161151 df = web .get_quote_yahoo (pd .Series (['GOOG' , 'AAPL' , 'GOOG' ]))
162152 assert_series_equal (df .ix [0 ], df .ix [2 ])
163153
164- @network
165154 def test_get_quote_string (self ):
166155 df = web .get_quote_yahoo ('GOOG' )
167156
168- @network
169157 def test_get_quote_string (self ):
170158 _yahoo_codes .update ({'MarketCap' : 'j1' })
171159 df = web .get_quote_yahoo ('GOOG' )
172160 self .assertFalse (pd .isnull (df ['MarketCap' ][0 ]))
173161
174- @network
175162 def test_get_quote_stringlist (self ):
176163 df = web .get_quote_yahoo (['GOOG' , 'AAPL' , 'GOOG' ])
177164 assert_series_equal (df .ix [0 ], df .ix [2 ])
178165
179- @network
180166 def test_get_components_dow_jones (self ):
181167 raise nose .SkipTest ('unreliable test, receive partial components back for dow_jones' )
182168
183169 df = web .get_components_yahoo ('^DJI' ) #Dow Jones
184170 assert isinstance (df , pd .DataFrame )
185171 self .assertEqual (len (df ), 30 )
186172
187- @network
188173 def test_get_components_dax (self ):
189174 raise nose .SkipTest ('unreliable test, receive partial components back for dax' )
190175
@@ -194,7 +179,6 @@ def test_get_components_dax(self):
194179 self .assertEqual (df [df .name .str .contains ('adidas' , case = False )].index ,
195180 'ADS.DE' )
196181
197- @network
198182 def test_get_components_nasdaq_100 (self ):
199183 # as of 7/12/13 the conditional will test false because the link is invalid
200184 raise nose .SkipTest ('unreliable test, receive partial components back for nasdaq_100' )
@@ -212,20 +196,17 @@ def test_get_components_nasdaq_100(self):
212196 index = ['@^NDX' ])
213197 assert_frame_equal (df , expected )
214198
215- @network
216199 def test_get_data_single_symbol (self ):
217200 #single symbol
218201 #http://finance.yahoo.com/q/hp?s=GOOG&a=09&b=08&c=2010&d=09&e=10&f=2010&g=d
219202 # just test that we succeed
220203 web .get_data_yahoo ('GOOG' )
221204
222- @network
223205 def test_get_data_multiple_symbols (self ):
224206 # just test that we succeed
225207 sl = ['AAPL' , 'AMZN' , 'GOOG' ]
226208 web .get_data_yahoo (sl , '2012' )
227209
228- @network
229210 def test_get_data_multiple_symbols_two_dates (self ):
230211 pan = web .get_data_yahoo (['GE' , 'MSFT' , 'INTC' ], 'JAN-01-12' ,
231212 'JAN-31-12' )
@@ -242,7 +223,6 @@ def test_get_data_multiple_symbols_two_dates(self):
242223 result = pan .Open .ix ['Jan-15-12' :'Jan-20-12' ]
243224 self .assertEqual (expected .shape , result .shape )
244225
245- @network
246226 def test_get_date_ret_index (self ):
247227 pan = web .get_data_yahoo (['GE' , 'INTC' , 'IBM' ], '1977' , '1987' ,
248228 ret_index = True )
@@ -281,7 +261,6 @@ def tearDownClass(cls):
281261 super (TestYahooOptions , cls ).tearDownClass ()
282262 del cls .aapl , cls .expiry
283263
284- @network
285264 def test_get_options_data (self ):
286265 # regression test GH6105
287266 self .assertRaises (ValueError , self .aapl .get_options_data , month = 3 )
@@ -293,7 +272,6 @@ def test_get_options_data(self):
293272 raise nose .SkipTest (e )
294273 self .assertTrue (len (options ) > 1 )
295274
296- @network
297275 def test_get_near_stock_price (self ):
298276 try :
299277 options = self .aapl .get_near_stock_price (call = True , put = True ,
@@ -302,55 +280,48 @@ def test_get_near_stock_price(self):
302280 raise nose .SkipTest (e )
303281 self .assertTrue (len (options ) > 1 )
304282
305- @network
306283 def test_get_call_data (self ):
307284 try :
308285 calls = self .aapl .get_call_data (expiry = self .expiry )
309286 except RemoteDataError as e :
310287 raise nose .SkipTest (e )
311288 self .assertTrue (len (calls ) > 1 )
312289
313- @network
314290 def test_get_put_data (self ):
315291 try :
316292 puts = self .aapl .get_put_data (expiry = self .expiry )
317293 except RemoteDataError as e :
318294 raise nose .SkipTest (e )
319295 self .assertTrue (len (puts ) > 1 )
320296
321- @network
322297 def test_get_expiry_dates (self ):
323298 try :
324299 dates , _ = self .aapl ._get_expiry_dates_and_links ()
325300 except RemoteDataError as e :
326301 raise nose .SkipTest (e )
327302 self .assertTrue (len (dates ) > 1 )
328303
329- @network
330304 def test_get_all_data (self ):
331305 try :
332306 data = self .aapl .get_all_data (put = True )
333307 except RemoteDataError as e :
334308 raise nose .SkipTest (e )
335309 self .assertTrue (len (data ) > 1 )
336310
337- @network
338311 def test_get_data_with_list (self ):
339312 try :
340313 data = self .aapl .get_call_data (expiry = self .aapl .expiry_dates )
341314 except RemoteDataError as e :
342315 raise nose .SkipTest (e )
343316 self .assertTrue (len (data ) > 1 )
344317
345- @network
346318 def test_get_all_data_calls_only (self ):
347319 try :
348320 data = self .aapl .get_all_data (call = True , put = False )
349321 except RemoteDataError as e :
350322 raise nose .SkipTest (e )
351323 self .assertTrue (len (data ) > 1 )
352324
353- @network
354325 def test_sample_page_price_quote_time1 (self ):
355326 #Tests the weekend quote time format
356327 price , quote_time = self .aapl ._get_underlying_price (self .html1 )
@@ -371,21 +342,17 @@ def test_chop_out_of_strike_range(self):
371342 self .assertIsInstance (chopped , DataFrame )
372343 self .assertTrue (len (chopped ) > 1 )
373344
374-
375- @network
376345 def test_sample_page_price_quote_time2 (self ):
377346 #Tests the EDT page format
378347 #regression test for #8741
379348 price , quote_time = self .aapl ._get_underlying_price (self .html2 )
380349 self .assertIsInstance (price , (int , float , complex ))
381350 self .assertIsInstance (quote_time , (datetime , Timestamp ))
382351
383- @network
384352 def test_sample_page_chg_float (self ):
385353 #Tests that numeric columns with comma's are appropriately dealt with
386354 self .assertEqual (self .data1 ['Chg' ].dtype , 'float64' )
387355
388- @network
389356 def test_month_year (self ):
390357 try :
391358 data = self .aapl .get_call_data (month = self .month , year = self .year )
@@ -404,7 +371,6 @@ def setUpClass(cls):
404371 def tearDownClass (cls ):
405372 super (TestOptionsWarnings , cls ).tearDownClass ()
406373
407- @network
408374 def test_options_source_warning (self ):
409375 if not assert_produces_warning :
410376 raise SkipTest ("old version of pandas without "
@@ -418,22 +384,18 @@ def test_is_s3_url(self):
418384 from pandas .io .common import _is_s3_url
419385 self .assertTrue (_is_s3_url ("s3://pandas/somethingelse.com" ))
420386
421- @network
422387 def test_read_yahoo (self ):
423388 gs = DataReader ("GS" , "yahoo" )
424389 assert isinstance (gs , DataFrame )
425390
426- @network
427391 def test_read_google (self ):
428392 gs = DataReader ("GS" , "google" )
429393 assert isinstance (gs , DataFrame )
430394
431- @network
432395 def test_read_fred (self ):
433396 vix = DataReader ("VIXCLS" , "fred" )
434397 assert isinstance (vix , DataFrame )
435398
436- @network
437399 def test_read_famafrench (self ):
438400 for name in ("F-F_Research_Data_Factors" ,
439401 "F-F_Research_Data_Factors_weekly" , "6_Portfolios_2x3" ,
@@ -444,7 +406,6 @@ def test_read_famafrench(self):
444406
445407
446408class TestFred (tm .TestCase ):
447- @network
448409 def test_fred (self ):
449410
450411 # Throws an exception when DataReader can't get a 200 response from
@@ -462,14 +423,12 @@ def test_fred(self):
462423 self .assertRaises (Exception , web .DataReader , "NON EXISTENT SERIES" ,
463424 'fred' , start , end )
464425
465- @network
466426 def test_fred_nan (self ):
467427 start = datetime (2010 , 1 , 1 )
468428 end = datetime (2013 , 1 , 27 )
469429 df = web .DataReader ("DFII5" , "fred" , start , end )
470430 assert pd .isnull (df .ix ['2010-01-01' ][0 ])
471431
472- @network
473432 def test_fred_parts (self ):
474433 raise nose .SkipTest ('buggy as of 2/18/14; maybe a data revision?' )
475434
@@ -482,7 +441,6 @@ def test_fred_parts(self):
482441 assert np .issubdtype (t .dtype , np .floating )
483442 self .assertEqual (t .shape , (37 ,))
484443
485- @network
486444 def test_fred_part2 (self ):
487445 expected = [[576.7 ],
488446 [962.9 ],
@@ -492,12 +450,10 @@ def test_fred_part2(self):
492450 result = web .get_data_fred ("A09024USA144NNBR" , start = "1915" ).ix [:5 ]
493451 assert_array_equal (result .values , np .array (expected ))
494452
495- @network
496453 def test_invalid_series (self ):
497454 name = "NOT A REAL SERIES"
498455 self .assertRaises (Exception , web .get_data_fred , name )
499456
500- @network
501457 def test_fred_multi (self ):
502458 raise nose .SkipTest ('buggy as of 2/18/14; maybe a data revision?' )
503459
@@ -511,7 +467,6 @@ def test_fred_multi(self):
511467 expected .index .rename ('DATE' , inplace = True )
512468 assert_frame_equal (received , expected , check_less_precise = True )
513469
514- @network
515470 def test_fred_multi_bad_series (self ):
516471
517472 names = ['NOTAREALSERIES' , 'CPIAUCSL' , "ALSO FAKE" ]
0 commit comments