Skip to content

Commit 5930bcc

Browse files
TST: Changed the error raised by no tables in data.io.Options
Tests were failing if the scraper got the webpage but there weren't any tables in it. Added condition to raise RemoteDataError if no tables were found. Still IndexError if it can't find the correct table.
1 parent ef9b818 commit 5930bcc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pandas/io/data.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,9 @@ def _get_option_data(self, month, year, expiry, table_loc, name):
664664
"element".format(url))
665665
tables = root.xpath('.//table')
666666
ntables = len(tables)
667-
if table_loc - 1 > ntables:
667+
if ntables == 0:
668+
raise RemoteDataError("No tables found at {0!r}".format(url))
669+
elif table_loc - 1 > ntables:
668670
raise IndexError("Table location {0} invalid, {1} tables"
669671
" found".format(table_loc, ntables))
670672

0 commit comments

Comments
 (0)