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