From 5bc618fdc5654b8b6cc2ff505b16a7f38c7a0bb3 Mon Sep 17 00:00:00 2001 From: Phillip Cloud Date: Thu, 24 Jul 2014 15:24:59 -0400 Subject: [PATCH 1/2] TST/BUG: html tests not skipping properly if lxml is not installed --- pandas/io/tests/test_html.py | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/pandas/io/tests/test_html.py b/pandas/io/tests/test_html.py index 326b7bc004564..6f6892a60b1c2 100644 --- a/pandas/io/tests/test_html.py +++ b/pandas/io/tests/test_html.py @@ -595,18 +595,28 @@ def _lang_enc(filename): class TestReadHtmlEncoding(tm.TestCase): files = glob.glob(os.path.join(DATA_PATH, 'html_encoding', '*.html')) + flavor = 'bs4' + + @classmethod + def setUpClass(cls): + super(TestReadHtmlEncoding, cls).setUpClass() + _skip_if_none_of((cls.flavor, 'html5lib')) + + def read_html(self, *args, **kwargs): + kwargs['flavor'] = self.flavor + return read_html(*args, **kwargs) def read_filename(self, f, encoding): - return read_html(f, encoding=encoding, index_col=0) + return self.read_html(f, encoding=encoding, index_col=0) def read_file_like(self, f, encoding): with open(f, 'rb') as fobj: - return read_html(BytesIO(fobj.read()), encoding=encoding, - index_col=0) + return self.read_html(BytesIO(fobj.read()), encoding=encoding, + index_col=0) def read_string(self, f, encoding): with open(f, 'rb') as fobj: - return read_html(fobj.read(), encoding=encoding, index_col=0) + return self.read_html(fobj.read(), encoding=encoding, index_col=0) def test_encode(self): for f in self.files: @@ -618,6 +628,15 @@ def test_encode(self): tm.assert_frame_equal(from_string, from_filename) +class TestReadHtmlEncodingLxml(TestReadHtmlEncoding): + flavor = 'lxml' + + @classmethod + def setUpClass(cls): + super(TestReadHtmlEncoding, cls).setUpClass() + _skip_if_no(cls.flavor) + + class TestReadHtmlLxml(tm.TestCase): @classmethod def setUpClass(cls): From 041abaaab031833f689eb67767bf4371db138a18 Mon Sep 17 00:00:00 2001 From: Phillip Cloud Date: Thu, 24 Jul 2014 15:25:56 -0400 Subject: [PATCH 2/2] BUG: forgot to super the right class --- pandas/io/tests/test_html.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/io/tests/test_html.py b/pandas/io/tests/test_html.py index 6f6892a60b1c2..a7540fc716e1f 100644 --- a/pandas/io/tests/test_html.py +++ b/pandas/io/tests/test_html.py @@ -633,7 +633,7 @@ class TestReadHtmlEncodingLxml(TestReadHtmlEncoding): @classmethod def setUpClass(cls): - super(TestReadHtmlEncoding, cls).setUpClass() + super(TestReadHtmlEncodingLxml, cls).setUpClass() _skip_if_no(cls.flavor)