2020from pandas import (DataFrame , MultiIndex , read_csv , Timestamp , Index ,
2121 date_range , Series )
2222from pandas .compat import (map , zip , StringIO , string_types , BytesIO ,
23- is_platform_windows )
23+ is_platform_windows , PY3 )
2424from pandas .io .common import URLError , urlopen , file_path_to_url
2525from pandas .io .html import read_html
2626from pandas ._libs .parsers import ParserError
@@ -96,6 +96,9 @@ def read_html(self, *args, **kwargs):
9696class TestReadHtml (ReadHtmlMixin ):
9797 flavor = 'bs4'
9898 spam_data = os .path .join (DATA_PATH , 'spam.html' )
99+ spam_data_kwargs = {}
100+ if PY3 :
101+ spam_data_kwargs ['encoding' ] = 'UTF-8'
99102 banklist_data = os .path .join (DATA_PATH , 'banklist.html' )
100103
101104 @classmethod
@@ -247,18 +250,18 @@ def test_infer_types(self):
247250 assert_framelist_equal (df1 , df2 )
248251
249252 def test_string_io (self ):
250- with open (self .spam_data ) as f :
253+ with open (self .spam_data , ** self . spam_data_kwargs ) as f :
251254 data1 = StringIO (f .read ())
252255
253- with open (self .spam_data ) as f :
256+ with open (self .spam_data , ** self . spam_data_kwargs ) as f :
254257 data2 = StringIO (f .read ())
255258
256259 df1 = self .read_html (data1 , '.*Water.*' )
257260 df2 = self .read_html (data2 , 'Unit' )
258261 assert_framelist_equal (df1 , df2 )
259262
260263 def test_string (self ):
261- with open (self .spam_data ) as f :
264+ with open (self .spam_data , ** self . spam_data_kwargs ) as f :
262265 data = f .read ()
263266
264267 df1 = self .read_html (data , '.*Water.*' )
@@ -267,10 +270,10 @@ def test_string(self):
267270 assert_framelist_equal (df1 , df2 )
268271
269272 def test_file_like (self ):
270- with open (self .spam_data ) as f :
273+ with open (self .spam_data , ** self . spam_data_kwargs ) as f :
271274 df1 = self .read_html (f , '.*Water.*' )
272275
273- with open (self .spam_data ) as f :
276+ with open (self .spam_data , ** self . spam_data_kwargs ) as f :
274277 df2 = self .read_html (f , 'Unit' )
275278
276279 assert_framelist_equal (df1 , df2 )
0 commit comments