@@ -138,7 +138,7 @@ def test_subdir_is_dir(self, alpharep):
138
138
def test_open (self , alpharep ):
139
139
root = zipp .Path (alpharep )
140
140
a , b , g = root .iterdir ()
141
- with a .open () as strm :
141
+ with a .open (encoding = "utf-8" ) as strm :
142
142
data = strm .read ()
143
143
assert data == "content of a"
144
144
@@ -150,7 +150,7 @@ def test_open_write(self):
150
150
zf = zipp .Path (zipfile .ZipFile (io .BytesIO (), mode = 'w' ))
151
151
with zf .joinpath ('file.bin' ).open ('wb' ) as strm :
152
152
strm .write (b'binary contents' )
153
- with zf .joinpath ('file.txt' ).open ('w' ) as strm :
153
+ with zf .joinpath ('file.txt' ).open ('w' , encoding = "utf-8" ) as strm :
154
154
strm .write ('text file' )
155
155
156
156
def test_open_extant_directory (self ):
@@ -181,7 +181,7 @@ def test_open_missing_directory(self):
181
181
def test_read (self , alpharep ):
182
182
root = zipp .Path (alpharep )
183
183
a , b , g = root .iterdir ()
184
- assert a .read_text () == "content of a"
184
+ assert a .read_text (encoding = "utf-8" ) == "content of a"
185
185
assert a .read_bytes () == b"content of a"
186
186
187
187
@pass_alpharep
@@ -190,21 +190,21 @@ def test_joinpath(self, alpharep):
190
190
a = root .joinpath ("a.txt" )
191
191
assert a .is_file ()
192
192
e = root .joinpath ("b" ).joinpath ("d" ).joinpath ("e.txt" )
193
- assert e .read_text () == "content of e"
193
+ assert e .read_text (encoding = "utf-8" ) == "content of e"
194
194
195
195
@pass_alpharep
196
196
def test_joinpath_multiple (self , alpharep ):
197
197
root = zipp .Path (alpharep )
198
198
e = root .joinpath ("b" , "d" , "e.txt" )
199
- assert e .read_text () == "content of e"
199
+ assert e .read_text (encoding = "utf-8" ) == "content of e"
200
200
201
201
@pass_alpharep
202
202
def test_traverse_truediv (self , alpharep ):
203
203
root = zipp .Path (alpharep )
204
204
a = root / "a.txt"
205
205
assert a .is_file ()
206
206
e = root / "b" / "d" / "e.txt"
207
- assert e .read_text () == "content of e"
207
+ assert e .read_text (encoding = "utf-8" ) == "content of e"
208
208
209
209
@pass_alpharep
210
210
def test_traverse_simplediv (self , alpharep ):
@@ -261,9 +261,9 @@ def test_mutability(self, alpharep):
261
261
alpharep .writestr ('foo.txt' , 'foo' )
262
262
alpharep .writestr ('bar/baz.txt' , 'baz' )
263
263
assert any (child .name == 'foo.txt' for child in root .iterdir ())
264
- assert (root / 'foo.txt' ).read_text () == 'foo'
264
+ assert (root / 'foo.txt' ).read_text (encoding = "utf-8" ) == 'foo'
265
265
(baz ,) = (root / 'bar' ).iterdir ()
266
- assert baz .read_text () == 'baz'
266
+ assert baz .read_text (encoding = "utf-8" ) == 'baz'
267
267
268
268
HUGE_ZIPFILE_NUM_ENTRIES = 2 ** 13
269
269
@@ -297,7 +297,7 @@ def test_read_does_not_close(self, alpharep):
297
297
alpharep = self .zipfile_ondisk (alpharep )
298
298
with zipfile .ZipFile (alpharep ) as file :
299
299
for rep in range (2 ):
300
- zipp .Path (file , 'a.txt' ).read_text ()
300
+ zipp .Path (file , 'a.txt' ).read_text (encoding = "utf-8" )
301
301
302
302
@pass_alpharep
303
303
def test_subclass (self , alpharep ):
0 commit comments