Skip to content

TST: Specify HTML file encoding on PY3 #16526

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions pandas/tests/io/test_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from pandas import (DataFrame, MultiIndex, read_csv, Timestamp, Index,
date_range, Series)
from pandas.compat import (map, zip, StringIO, string_types, BytesIO,
is_platform_windows)
is_platform_windows, PY3)
from pandas.io.common import URLError, urlopen, file_path_to_url
from pandas.io.html import read_html
from pandas._libs.parsers import ParserError
Expand Down Expand Up @@ -96,6 +96,9 @@ def read_html(self, *args, **kwargs):
class TestReadHtml(ReadHtmlMixin):
flavor = 'bs4'
spam_data = os.path.join(DATA_PATH, 'spam.html')
spam_data_kwargs = {}
if PY3:
spam_data_kwargs['encoding'] = 'UTF-8'
banklist_data = os.path.join(DATA_PATH, 'banklist.html')

@classmethod
Expand Down Expand Up @@ -247,18 +250,18 @@ def test_infer_types(self):
assert_framelist_equal(df1, df2)

def test_string_io(self):
with open(self.spam_data) as f:
with open(self.spam_data, **self.spam_data_kwargs) as f:
data1 = StringIO(f.read())

with open(self.spam_data) as f:
with open(self.spam_data, **self.spam_data_kwargs) as f:
data2 = StringIO(f.read())

df1 = self.read_html(data1, '.*Water.*')
df2 = self.read_html(data2, 'Unit')
assert_framelist_equal(df1, df2)

def test_string(self):
with open(self.spam_data) as f:
with open(self.spam_data, **self.spam_data_kwargs) as f:
data = f.read()

df1 = self.read_html(data, '.*Water.*')
Expand All @@ -267,10 +270,10 @@ def test_string(self):
assert_framelist_equal(df1, df2)

def test_file_like(self):
with open(self.spam_data) as f:
with open(self.spam_data, **self.spam_data_kwargs) as f:
df1 = self.read_html(f, '.*Water.*')

with open(self.spam_data) as f:
with open(self.spam_data, **self.spam_data_kwargs) as f:
df2 = self.read_html(f, 'Unit')

assert_framelist_equal(df1, df2)
Expand Down