Skip to content

Commit ad90f82

Browse files
committed
Merge pull request #7836 from cpcloud/read-html-test-fix
TST/BUG: html tests not skipping properly if lxml is not installed
2 parents 6cba473 + 041abaa commit ad90f82

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

pandas/io/tests/test_html.py

+23-4
Original file line numberDiff line numberDiff line change
@@ -595,18 +595,28 @@ def _lang_enc(filename):
595595

596596
class TestReadHtmlEncoding(tm.TestCase):
597597
files = glob.glob(os.path.join(DATA_PATH, 'html_encoding', '*.html'))
598+
flavor = 'bs4'
599+
600+
@classmethod
601+
def setUpClass(cls):
602+
super(TestReadHtmlEncoding, cls).setUpClass()
603+
_skip_if_none_of((cls.flavor, 'html5lib'))
604+
605+
def read_html(self, *args, **kwargs):
606+
kwargs['flavor'] = self.flavor
607+
return read_html(*args, **kwargs)
598608

599609
def read_filename(self, f, encoding):
600-
return read_html(f, encoding=encoding, index_col=0)
610+
return self.read_html(f, encoding=encoding, index_col=0)
601611

602612
def read_file_like(self, f, encoding):
603613
with open(f, 'rb') as fobj:
604-
return read_html(BytesIO(fobj.read()), encoding=encoding,
605-
index_col=0)
614+
return self.read_html(BytesIO(fobj.read()), encoding=encoding,
615+
index_col=0)
606616

607617
def read_string(self, f, encoding):
608618
with open(f, 'rb') as fobj:
609-
return read_html(fobj.read(), encoding=encoding, index_col=0)
619+
return self.read_html(fobj.read(), encoding=encoding, index_col=0)
610620

611621
def test_encode(self):
612622
for f in self.files:
@@ -618,6 +628,15 @@ def test_encode(self):
618628
tm.assert_frame_equal(from_string, from_filename)
619629

620630

631+
class TestReadHtmlEncodingLxml(TestReadHtmlEncoding):
632+
flavor = 'lxml'
633+
634+
@classmethod
635+
def setUpClass(cls):
636+
super(TestReadHtmlEncodingLxml, cls).setUpClass()
637+
_skip_if_no(cls.flavor)
638+
639+
621640
class TestReadHtmlLxml(tm.TestCase):
622641
@classmethod
623642
def setUpClass(cls):

0 commit comments

Comments
 (0)