Skip to content

Commit 9f52743

Browse files
Tests for LocalOperations methods isdir and isfile are added
1 parent 2f3fc40 commit 9f52743

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

tests/test_local.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,67 @@ def test_get_file_size__unk_file(self):
118118

119119
with pytest.raises(FileNotFoundError, match=re.escape("[Errno 2] No such file or directory: '/dummy'")):
120120
self.operations.get_file_size("/dummy")
121+
122+
def test_isfile_true(self):
123+
"""
124+
Test isfile for an existing file.
125+
"""
126+
filename = __file__
127+
128+
response = self.operations.isfile(filename)
129+
130+
assert response is True
131+
132+
def test_isfile_false__not_exist(self):
133+
"""
134+
Test isfile for a non-existing file.
135+
"""
136+
filename = os.path.join(os.path.dirname(__file__), "nonexistent_file.txt")
137+
138+
response = self.operations.isfile(filename)
139+
140+
assert response is False
141+
142+
def test_isfile_false__directory(self):
143+
"""
144+
Test isfile for a firectory.
145+
"""
146+
name = os.path.dirname(__file__)
147+
148+
assert self.operations.isdir(name)
149+
150+
response = self.operations.isfile(name)
151+
152+
assert response is False
153+
154+
def test_isdir_true(self):
155+
"""
156+
Test isdir for an existing directory.
157+
"""
158+
name = os.path.dirname(__file__)
159+
160+
response = self.operations.isdir(name)
161+
162+
assert response is True
163+
164+
def test_isdir_false__not_exist(self):
165+
"""
166+
Test isdir for a non-existing directory.
167+
"""
168+
name = os.path.join(os.path.dirname(__file__), "it_is_nonexistent_directory")
169+
170+
response = self.operations.isdir(name)
171+
172+
assert response is False
173+
174+
def test_isdir_false__file(self):
175+
"""
176+
Test isdir for a file.
177+
"""
178+
name = __file__
179+
180+
assert self.operations.isfile(name)
181+
182+
response = self.operations.isdir(name)
183+
184+
assert response is False

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy