Skip to content

Commit 67b9f38

Browse files
author
uunal
authored
add sftp registration (#35)
1 parent dca7d9b commit 67b9f38

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ pywin32 = asyncssh[pywin32]
3030
[options.entry_points]
3131
fsspec.specs =
3232
ssh = sshfs.spec:SSHFileSystem
33+
sftp = sshfs.spec:SSHFileSystem

tests/test_sshfs.py

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import tempfile
55
import warnings
66
from concurrent import futures
7-
from datetime import datetime, timedelta
87
from pathlib import Path
98

109
import fsspec
10+
import pkg_resources
1111
import pytest
1212
from asyncssh.sftp import SFTPFailure
1313

@@ -73,28 +73,30 @@ def strip_keys(info):
7373

7474

7575
def test_fsspec_registration(ssh_server):
76-
fs = fsspec.filesystem(
77-
"ssh",
78-
host=ssh_server.host,
79-
port=ssh_server.port,
80-
username="user",
81-
client_keys=[USERS["user"]],
82-
)
83-
assert isinstance(fs, SSHFileSystem)
76+
for ep in pkg_resources.iter_entry_points(group="fsspec.specs"):
77+
fs = fsspec.filesystem(
78+
ep.name,
79+
host=ssh_server.host,
80+
port=ssh_server.port,
81+
username="user",
82+
client_keys=[USERS["user"]],
83+
)
84+
assert isinstance(fs, SSHFileSystem)
8485

8586

8687
def test_fsspec_url_parsing(ssh_server, remote_dir, user="user"):
87-
url = f"ssh://{user}@{ssh_server.host}:{ssh_server.port}/{remote_dir}/file"
88-
with fsspec.open(url, "w", client_keys=[USERS[user]]) as file:
89-
# Check the underlying file system.
90-
file_fs = file.buffer.fs
91-
assert isinstance(file_fs, SSHFileSystem)
92-
assert file_fs.storage_options == {
93-
"host": ssh_server.host,
94-
"port": ssh_server.port,
95-
"username": user,
96-
"client_keys": [USERS[user]],
97-
}
88+
for ep in pkg_resources.iter_entry_points(group="fsspec.specs"):
89+
url = f"{ep.name}://{user}@{ssh_server.host}:{ssh_server.port}/{remote_dir}/file"
90+
with fsspec.open(url, "w", client_keys=[USERS[user]]) as file:
91+
# Check the underlying file system.
92+
file_fs = file.buffer.fs
93+
assert isinstance(file_fs, SSHFileSystem)
94+
assert file_fs.storage_options == {
95+
"host": ssh_server.host,
96+
"port": ssh_server.port,
97+
"username": user,
98+
"client_keys": [USERS[user]],
99+
}
98100

99101

100102
def test_info(fs, remote_dir):

0 commit comments

Comments
 (0)