@@ -97,9 +97,9 @@ def setup_method(self, method):
97
97
98
98
self .stata_dates = os .path .join (self .dirpath , 'stata13_dates.dta' )
99
99
100
- def read_dta (self , file ):
100
+ def read_dta (self , file , encoding = 'latin-1' ):
101
101
# Legacy default reader configuration
102
- return read_stata (file , convert_dates = True )
102
+ return read_stata (file , convert_dates = True , encoding = encoding )
103
103
104
104
def read_csv (self , file ):
105
105
return read_csv (file , parse_dates = True )
@@ -266,7 +266,7 @@ def test_read_dta12(self):
266
266
tm .assert_frame_equal (parsed_117 , expected , check_dtype = False )
267
267
268
268
def test_read_dta18 (self ):
269
- parsed_118 = self .read_dta (self .dta22_118 )
269
+ parsed_118 = self .read_dta (self .dta22_118 , encoding = 'utf-8' )
270
270
parsed_118 ["Bytes" ] = parsed_118 ["Bytes" ].astype ('O' )
271
271
expected = DataFrame .from_records (
272
272
[['Cat' , 'Bogota' , u'Bogotá' , 1 , 1.0 , u'option b Ünicode' , 1.0 ],
@@ -281,7 +281,7 @@ def test_read_dta18(self):
281
281
for col in parsed_118 .columns :
282
282
tm .assert_almost_equal (parsed_118 [col ], expected [col ])
283
283
284
- with StataReader (self .dta22_118 ) as rdr :
284
+ with StataReader (self .dta22_118 , encoding = 'utf-8' ) as rdr :
285
285
vl = rdr .variable_labels ()
286
286
vl_expected = {u'Unicode_Cities_Strl' :
287
287
u'Here are some strls with Ünicode chars' ,
@@ -1356,7 +1356,7 @@ def test_invalid_encoding(self):
1356
1356
original = self .read_csv (self .csv3 )
1357
1357
with pytest .raises (ValueError ):
1358
1358
with tm .ensure_clean () as path :
1359
- original .to_stata (path , encoding = 'utf-8 ' )
1359
+ original .to_stata (path , encoding = 'pokemon ' )
1360
1360
1361
1361
def test_path_pathlib (self ):
1362
1362
df = tm .makeDataFrame ()
0 commit comments