Skip to content

Commit

Permalink
Final update to fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bartvaneswhiffle committed Aug 8, 2024
1 parent 0c0b9b5 commit 817525b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
8 changes: 4 additions & 4 deletions fsspec/implementations/tests/ftp_tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@


def ftp():
"""Script to run FTP server that accepts TLS"""
# Set up FTP server parameters
FTP_HOST = "0.0.0.0"
FTP_PORT = 2121 # Choose a free port for the FTP server
FTP_DIRECTORY = os.path.dirname(__file__)
print(FTP_DIRECTORY)
FTP_HOST = "localhost"
FTP_PORT = 2121
FTP_DIRECTORY = os.path.dirname(os.path.abspath(__file__))

# Instantiate a dummy authorizer
authorizer = DummyAuthorizer()
Expand Down
15 changes: 12 additions & 3 deletions fsspec/implementations/tests/test_ftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
def ftp():
pytest.importorskip("pyftpdlib")
P = subprocess.Popen(
[sys.executable, "-m", "pyftpdlib", "-d", here],
[sys.executable, os.path.join(here, "ftp_tls.py")],
stderr=subprocess.STDOUT,
stdout=subprocess.PIPE,
)
Expand All @@ -43,9 +43,18 @@ def test_tls(ftp, tls, exp_cls):
assert isinstance(fs.ftp, exp_cls)


def test_basic(ftp):
@pytest.mark.parametrize(
"tls,username,password",
(
(False, "", ""),
(True, "", ""),
(False, "user", "pass"),
(True, "user", "pass"),
),
)
def test_basic(ftp, tls, username, password):
host, port = ftp
fs = FTPFileSystem(host, port)
fs = FTPFileSystem(host, port, username, password, tls=tls)
assert fs.ls("/", detail=False) == sorted(os.listdir(here))
out = fs.cat(f"/{os.path.basename(__file__)}")
assert out == open(__file__, "rb").read()
Expand Down

0 comments on commit 817525b

Please sign in to comment.