Skip to content

Commit 9e81317

Browse files
committed
test: read_html() parse error interaction with unseekable IO
1 parent 0d4b418 commit 9e81317

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

pandas/tests/io/test_html.py

+24
Original file line numberDiff line numberDiff line change
@@ -967,3 +967,27 @@ 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+
# Issue #17975
974+
_skip_if_no('lxml')
975+
976+
class UnseekableStringIO(StringIO):
977+
def seekable(self):
978+
return False
979+
980+
good = UnseekableStringIO('''
981+
<table><tr><td>spam<br />eggs</td></tr></table>''')
982+
bad = UnseekableStringIO('''
983+
<table><tr><td>spam<foobr />eggs</td></tr></table>''')
984+
985+
assert read_html(good)
986+
assert read_html(bad, flavor='bs4')
987+
988+
bad.seek(0)
989+
990+
with pytest.raises(ValueError,
991+
match='passed a non-rewindable file object'):
992+
read_html(bad)
993+

0 commit comments

Comments
 (0)