9
9
import numpy as np
10
10
import pandas as pd
11
11
from 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
14
13
try :
15
14
from pandas .util .testing import assert_produces_warning
16
15
except ImportError :
@@ -59,7 +58,6 @@ def tearDownClass(cls):
59
58
super (TestGoogle , cls ).tearDownClass ()
60
59
del cls .locales
61
60
62
- @network
63
61
def test_google (self ):
64
62
# asserts that google is minimally working and that it throws
65
63
# an exception when DataReader can't get a 200 response from
@@ -75,19 +73,16 @@ def test_google(self):
75
73
self .assertRaises (Exception , web .DataReader , "NON EXISTENT TICKER" ,
76
74
'google' , start , end )
77
75
78
- @network
79
76
def test_get_quote_fails (self ):
80
77
self .assertRaises (NotImplementedError , web .get_quote_google ,
81
78
pd .Series (['GOOG' , 'AAPL' , 'GOOG' ]))
82
79
83
- @network
84
80
def test_get_goog_volume (self ):
85
81
for locale in self .locales :
86
82
with tm .set_locale (locale ):
87
83
df = web .get_data_google ('GOOG' ).sort_index ()
88
84
self .assertEqual (df .Volume .ix ['OCT-08-2010' ], 2863473 )
89
85
90
- @network
91
86
def test_get_multi1 (self ):
92
87
for locale in self .locales :
93
88
sl = ['AAPL' , 'AMZN' , 'GOOG' ]
@@ -100,13 +95,11 @@ def test_get_multi1(self):
100
95
else :
101
96
self .assertRaises (AttributeError , lambda : pan .Close )
102
97
103
- @network
104
98
def test_get_multi_invalid (self ):
105
99
sl = ['AAPL' , 'AMZN' , 'INVALID' ]
106
100
pan = web .get_data_google (sl , '2012' )
107
101
self .assertIn ('INVALID' , pan .minor_axis )
108
102
109
- @network
110
103
def test_get_multi2 (self ):
111
104
with warnings .catch_warnings (record = True ) as w :
112
105
for locale in self .locales :
@@ -138,7 +131,6 @@ def setUpClass(cls):
138
131
super (TestYahoo , cls ).setUpClass ()
139
132
_skip_if_no_lxml ()
140
133
141
- @network
142
134
def test_yahoo (self ):
143
135
# asserts that yahoo is minimally working and that it throws
144
136
# an exception when DataReader can't get a 200 response from
@@ -149,42 +141,35 @@ def test_yahoo(self):
149
141
self .assertEqual (web .DataReader ("F" , 'yahoo' , start , end )['Close' ][- 1 ],
150
142
13.68 )
151
143
152
- @network
153
144
def test_yahoo_fails (self ):
154
145
start = datetime (2010 , 1 , 1 )
155
146
end = datetime (2013 , 1 , 27 )
156
147
self .assertRaises (Exception , web .DataReader , "NON EXISTENT TICKER" ,
157
148
'yahoo' , start , end )
158
149
159
- @network
160
150
def test_get_quote_series (self ):
161
151
df = web .get_quote_yahoo (pd .Series (['GOOG' , 'AAPL' , 'GOOG' ]))
162
152
assert_series_equal (df .ix [0 ], df .ix [2 ])
163
153
164
- @network
165
154
def test_get_quote_string (self ):
166
155
df = web .get_quote_yahoo ('GOOG' )
167
156
168
- @network
169
157
def test_get_quote_string (self ):
170
158
_yahoo_codes .update ({'MarketCap' : 'j1' })
171
159
df = web .get_quote_yahoo ('GOOG' )
172
160
self .assertFalse (pd .isnull (df ['MarketCap' ][0 ]))
173
161
174
- @network
175
162
def test_get_quote_stringlist (self ):
176
163
df = web .get_quote_yahoo (['GOOG' , 'AAPL' , 'GOOG' ])
177
164
assert_series_equal (df .ix [0 ], df .ix [2 ])
178
165
179
- @network
180
166
def test_get_components_dow_jones (self ):
181
167
raise nose .SkipTest ('unreliable test, receive partial components back for dow_jones' )
182
168
183
169
df = web .get_components_yahoo ('^DJI' ) #Dow Jones
184
170
assert isinstance (df , pd .DataFrame )
185
171
self .assertEqual (len (df ), 30 )
186
172
187
- @network
188
173
def test_get_components_dax (self ):
189
174
raise nose .SkipTest ('unreliable test, receive partial components back for dax' )
190
175
@@ -194,7 +179,6 @@ def test_get_components_dax(self):
194
179
self .assertEqual (df [df .name .str .contains ('adidas' , case = False )].index ,
195
180
'ADS.DE' )
196
181
197
- @network
198
182
def test_get_components_nasdaq_100 (self ):
199
183
# as of 7/12/13 the conditional will test false because the link is invalid
200
184
raise nose .SkipTest ('unreliable test, receive partial components back for nasdaq_100' )
@@ -212,20 +196,17 @@ def test_get_components_nasdaq_100(self):
212
196
index = ['@^NDX' ])
213
197
assert_frame_equal (df , expected )
214
198
215
- @network
216
199
def test_get_data_single_symbol (self ):
217
200
#single symbol
218
201
#http://finance.yahoo.com/q/hp?s=GOOG&a=09&b=08&c=2010&d=09&e=10&f=2010&g=d
219
202
# just test that we succeed
220
203
web .get_data_yahoo ('GOOG' )
221
204
222
- @network
223
205
def test_get_data_multiple_symbols (self ):
224
206
# just test that we succeed
225
207
sl = ['AAPL' , 'AMZN' , 'GOOG' ]
226
208
web .get_data_yahoo (sl , '2012' )
227
209
228
- @network
229
210
def test_get_data_multiple_symbols_two_dates (self ):
230
211
pan = web .get_data_yahoo (['GE' , 'MSFT' , 'INTC' ], 'JAN-01-12' ,
231
212
'JAN-31-12' )
@@ -242,7 +223,6 @@ def test_get_data_multiple_symbols_two_dates(self):
242
223
result = pan .Open .ix ['Jan-15-12' :'Jan-20-12' ]
243
224
self .assertEqual (expected .shape , result .shape )
244
225
245
- @network
246
226
def test_get_date_ret_index (self ):
247
227
pan = web .get_data_yahoo (['GE' , 'INTC' , 'IBM' ], '1977' , '1987' ,
248
228
ret_index = True )
@@ -281,7 +261,6 @@ def tearDownClass(cls):
281
261
super (TestYahooOptions , cls ).tearDownClass ()
282
262
del cls .aapl , cls .expiry
283
263
284
- @network
285
264
def test_get_options_data (self ):
286
265
# regression test GH6105
287
266
self .assertRaises (ValueError , self .aapl .get_options_data , month = 3 )
@@ -293,7 +272,6 @@ def test_get_options_data(self):
293
272
raise nose .SkipTest (e )
294
273
self .assertTrue (len (options ) > 1 )
295
274
296
- @network
297
275
def test_get_near_stock_price (self ):
298
276
try :
299
277
options = self .aapl .get_near_stock_price (call = True , put = True ,
@@ -302,55 +280,48 @@ def test_get_near_stock_price(self):
302
280
raise nose .SkipTest (e )
303
281
self .assertTrue (len (options ) > 1 )
304
282
305
- @network
306
283
def test_get_call_data (self ):
307
284
try :
308
285
calls = self .aapl .get_call_data (expiry = self .expiry )
309
286
except RemoteDataError as e :
310
287
raise nose .SkipTest (e )
311
288
self .assertTrue (len (calls ) > 1 )
312
289
313
- @network
314
290
def test_get_put_data (self ):
315
291
try :
316
292
puts = self .aapl .get_put_data (expiry = self .expiry )
317
293
except RemoteDataError as e :
318
294
raise nose .SkipTest (e )
319
295
self .assertTrue (len (puts ) > 1 )
320
296
321
- @network
322
297
def test_get_expiry_dates (self ):
323
298
try :
324
299
dates , _ = self .aapl ._get_expiry_dates_and_links ()
325
300
except RemoteDataError as e :
326
301
raise nose .SkipTest (e )
327
302
self .assertTrue (len (dates ) > 1 )
328
303
329
- @network
330
304
def test_get_all_data (self ):
331
305
try :
332
306
data = self .aapl .get_all_data (put = True )
333
307
except RemoteDataError as e :
334
308
raise nose .SkipTest (e )
335
309
self .assertTrue (len (data ) > 1 )
336
310
337
- @network
338
311
def test_get_data_with_list (self ):
339
312
try :
340
313
data = self .aapl .get_call_data (expiry = self .aapl .expiry_dates )
341
314
except RemoteDataError as e :
342
315
raise nose .SkipTest (e )
343
316
self .assertTrue (len (data ) > 1 )
344
317
345
- @network
346
318
def test_get_all_data_calls_only (self ):
347
319
try :
348
320
data = self .aapl .get_all_data (call = True , put = False )
349
321
except RemoteDataError as e :
350
322
raise nose .SkipTest (e )
351
323
self .assertTrue (len (data ) > 1 )
352
324
353
- @network
354
325
def test_sample_page_price_quote_time1 (self ):
355
326
#Tests the weekend quote time format
356
327
price , quote_time = self .aapl ._get_underlying_price (self .html1 )
@@ -371,21 +342,17 @@ def test_chop_out_of_strike_range(self):
371
342
self .assertIsInstance (chopped , DataFrame )
372
343
self .assertTrue (len (chopped ) > 1 )
373
344
374
-
375
- @network
376
345
def test_sample_page_price_quote_time2 (self ):
377
346
#Tests the EDT page format
378
347
#regression test for #8741
379
348
price , quote_time = self .aapl ._get_underlying_price (self .html2 )
380
349
self .assertIsInstance (price , (int , float , complex ))
381
350
self .assertIsInstance (quote_time , (datetime , Timestamp ))
382
351
383
- @network
384
352
def test_sample_page_chg_float (self ):
385
353
#Tests that numeric columns with comma's are appropriately dealt with
386
354
self .assertEqual (self .data1 ['Chg' ].dtype , 'float64' )
387
355
388
- @network
389
356
def test_month_year (self ):
390
357
try :
391
358
data = self .aapl .get_call_data (month = self .month , year = self .year )
@@ -404,7 +371,6 @@ def setUpClass(cls):
404
371
def tearDownClass (cls ):
405
372
super (TestOptionsWarnings , cls ).tearDownClass ()
406
373
407
- @network
408
374
def test_options_source_warning (self ):
409
375
if not assert_produces_warning :
410
376
raise SkipTest ("old version of pandas without "
@@ -418,22 +384,18 @@ def test_is_s3_url(self):
418
384
from pandas .io .common import _is_s3_url
419
385
self .assertTrue (_is_s3_url ("s3://pandas/somethingelse.com" ))
420
386
421
- @network
422
387
def test_read_yahoo (self ):
423
388
gs = DataReader ("GS" , "yahoo" )
424
389
assert isinstance (gs , DataFrame )
425
390
426
- @network
427
391
def test_read_google (self ):
428
392
gs = DataReader ("GS" , "google" )
429
393
assert isinstance (gs , DataFrame )
430
394
431
- @network
432
395
def test_read_fred (self ):
433
396
vix = DataReader ("VIXCLS" , "fred" )
434
397
assert isinstance (vix , DataFrame )
435
398
436
- @network
437
399
def test_read_famafrench (self ):
438
400
for name in ("F-F_Research_Data_Factors" ,
439
401
"F-F_Research_Data_Factors_weekly" , "6_Portfolios_2x3" ,
@@ -444,7 +406,6 @@ def test_read_famafrench(self):
444
406
445
407
446
408
class TestFred (tm .TestCase ):
447
- @network
448
409
def test_fred (self ):
449
410
450
411
# Throws an exception when DataReader can't get a 200 response from
@@ -462,14 +423,12 @@ def test_fred(self):
462
423
self .assertRaises (Exception , web .DataReader , "NON EXISTENT SERIES" ,
463
424
'fred' , start , end )
464
425
465
- @network
466
426
def test_fred_nan (self ):
467
427
start = datetime (2010 , 1 , 1 )
468
428
end = datetime (2013 , 1 , 27 )
469
429
df = web .DataReader ("DFII5" , "fred" , start , end )
470
430
assert pd .isnull (df .ix ['2010-01-01' ][0 ])
471
431
472
- @network
473
432
def test_fred_parts (self ):
474
433
raise nose .SkipTest ('buggy as of 2/18/14; maybe a data revision?' )
475
434
@@ -482,7 +441,6 @@ def test_fred_parts(self):
482
441
assert np .issubdtype (t .dtype , np .floating )
483
442
self .assertEqual (t .shape , (37 ,))
484
443
485
- @network
486
444
def test_fred_part2 (self ):
487
445
expected = [[576.7 ],
488
446
[962.9 ],
@@ -492,12 +450,10 @@ def test_fred_part2(self):
492
450
result = web .get_data_fred ("A09024USA144NNBR" , start = "1915" ).ix [:5 ]
493
451
assert_array_equal (result .values , np .array (expected ))
494
452
495
- @network
496
453
def test_invalid_series (self ):
497
454
name = "NOT A REAL SERIES"
498
455
self .assertRaises (Exception , web .get_data_fred , name )
499
456
500
- @network
501
457
def test_fred_multi (self ):
502
458
raise nose .SkipTest ('buggy as of 2/18/14; maybe a data revision?' )
503
459
@@ -511,7 +467,6 @@ def test_fred_multi(self):
511
467
expected .index .rename ('DATE' , inplace = True )
512
468
assert_frame_equal (received , expected , check_less_precise = True )
513
469
514
- @network
515
470
def test_fred_multi_bad_series (self ):
516
471
517
472
names = ['NOTAREALSERIES' , 'CPIAUCSL' , "ALSO FAKE" ]
0 commit comments