File tree 3 files changed +10
-3
lines changed
3 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ close the same file handle.
9
9
#56 and bpo-41035: ``Path._next `` now honors
10
10
subclasses.
11
11
12
+ #55: ``Path.is_file() `` now returns False for non-existent names.
13
+
12
14
v3.1.0
13
15
======
14
16
Original file line number Diff line number Diff line change @@ -107,6 +107,11 @@ def test_iterdir_and_types(self):
107
107
(i ,) = h .iterdir ()
108
108
assert i .is_file ()
109
109
110
+ def test_is_file_missing (self ):
111
+ for alpharep in self .zipfile_alpharep ():
112
+ root = zipp .Path (alpharep )
113
+ assert not root .joinpath ('missing.txt' ).is_file ()
114
+
110
115
def test_iterdir_on_file (self ):
111
116
for alpharep in self .zipfile_alpharep ():
112
117
root = zipp .Path (alpharep )
@@ -175,15 +180,15 @@ def test_read(self):
175
180
def test_joinpath (self ):
176
181
for alpharep in self .zipfile_alpharep ():
177
182
root = zipp .Path (alpharep )
178
- a = root .joinpath ("a" )
183
+ a = root .joinpath ("a.txt " )
179
184
assert a .is_file ()
180
185
e = root .joinpath ("b" ).joinpath ("d" ).joinpath ("e.txt" )
181
186
assert e .read_text () == "content of e"
182
187
183
188
def test_traverse_truediv (self ):
184
189
for alpharep in self .zipfile_alpharep ():
185
190
root = zipp .Path (alpharep )
186
- a = root / "a"
191
+ a = root / "a.txt "
187
192
assert a .is_file ()
188
193
e = root / "b" / "d" / "e.txt"
189
194
assert e .read_text () == "content of e"
Original file line number Diff line number Diff line change @@ -263,7 +263,7 @@ def is_dir(self):
263
263
return not self .at or self .at .endswith ("/" )
264
264
265
265
def is_file (self ):
266
- return not self .is_dir ()
266
+ return self . exists () and not self .is_dir ()
267
267
268
268
def exists (self ):
269
269
return self .at in self .root ._name_set ()
You can’t perform that action at this time.
0 commit comments