Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

OsOperations.isdir is added#166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletionstestgres/operations/os_ops.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -107,6 +107,9 @@ def read_binary(self, filename, start_pos):
def isfile(self, remote_file):
raise NotImplementedError()

def isdir(self, dirname):
raise NotImplementedError()

def get_file_size(self, filename):
raise NotImplementedError()

Expand Down
64 changes: 64 additions & 0 deletionstests/test_local.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -118,3 +118,67 @@ def test_get_file_size__unk_file(self):

with pytest.raises(FileNotFoundError, match=re.escape("[Errno 2] No such file or directory: '/dummy'")):
self.operations.get_file_size("/dummy")

def test_isfile_true(self):
"""
Test isfile for an existing file.
"""
filename = __file__

response = self.operations.isfile(filename)

assert response is True

def test_isfile_false__not_exist(self):
"""
Test isfile for a non-existing file.
"""
filename = os.path.join(os.path.dirname(__file__), "nonexistent_file.txt")

response = self.operations.isfile(filename)

assert response is False

def test_isfile_false__directory(self):
"""
Test isfile for a firectory.
"""
name = os.path.dirname(__file__)

assert self.operations.isdir(name)

response = self.operations.isfile(name)

assert response is False

def test_isdir_true(self):
"""
Test isdir for an existing directory.
"""
name = os.path.dirname(__file__)

response = self.operations.isdir(name)

assert response is True

def test_isdir_false__not_exist(self):
"""
Test isdir for a non-existing directory.
"""
name = os.path.join(os.path.dirname(__file__), "it_is_nonexistent_directory")

response = self.operations.isdir(name)

assert response is False

def test_isdir_false__file(self):
"""
Test isdir for a file.
"""
name = __file__

assert self.operations.isfile(name)

response = self.operations.isdir(name)

assert response is False
50 changes: 47 additions & 3 deletionstests/test_remote.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -259,18 +259,62 @@ def test_isfile_true(self):
"""
Test isfile for an existing file.
"""
filename ="/etc/hosts"
filename =__file__

response = self.operations.isfile(filename)

assert response is True

deftest_isfile_false(self):
deftest_isfile_false__not_exist(self):
"""
Test isfile for a non-existing file.
"""
filename ="/nonexistent_file.txt"
filename =os.path.join(os.path.dirname(__file__), "nonexistent_file.txt")

response = self.operations.isfile(filename)

assert response is False

def test_isfile_false__directory(self):
"""
Test isfile for a firectory.
"""
name = os.path.dirname(__file__)

assert self.operations.isdir(name)

response = self.operations.isfile(name)

assert response is False

def test_isdir_true(self):
"""
Test isdir for an existing directory.
"""
name = os.path.dirname(__file__)

response = self.operations.isdir(name)

assert response is True

def test_isdir_false__not_exist(self):
"""
Test isdir for a non-existing directory.
"""
name = os.path.join(os.path.dirname(__file__), "it_is_nonexistent_directory")

response = self.operations.isdir(name)

assert response is False

def test_isdir_false__file(self):
"""
Test isdir for a file.
"""
name = __file__

assert self.operations.isfile(name)

response = self.operations.isdir(name)

assert response is False

[8]ページ先頭

©2009-2025 Movatter.jp