Skip to content

Commit ec4bd0b

Browse files
committed
test: read_html() parse error interaction with unseekable IO
1 parent 464c4ce commit ec4bd0b

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

pandas/tests/io/test_html.py

+23
Original file line numberDiff line numberDiff line change
@@ -967,3 +967,26 @@ def test_importcheck_thread_safety():
967967
while helper_thread1.is_alive() or helper_thread2.is_alive():
968968
pass
969969
assert None is helper_thread1.err is helper_thread2.err
970+
971+
972+
def test_parse_failure_unseekable():
973+
_skip_if_no('lxml')
974+
975+
class UnseekableStringIO(StringIO):
976+
def seekable(self):
977+
return False
978+
979+
good = UnseekableStringIO('''
980+
<table><tr><td>spam<br />eggs</td></tr></table>''')
981+
bad = UnseekableStringIO('''
982+
<table><tr><td>spam<foobr />eggs</td></tr></table>''')
983+
984+
assert read_html(good)
985+
assert read_html(bad, flavor='bs4')
986+
987+
bad.seek(0)
988+
989+
with pytest.raises(ValueError,
990+
match='passed a non-rewindable file object'):
991+
read_html(bad)
992+

0 commit comments

Comments
 (0)