From 817525bd325f50f6dd57bc0dff6b8caa8a2506fe Mon Sep 17 00:00:00 2001 From: Bart van Es Date: Thu, 8 Aug 2024 13:27:15 +0200 Subject: [PATCH] Final update to fix tests --- fsspec/implementations/tests/ftp_tls.py | 8 ++++---- fsspec/implementations/tests/test_ftp.py | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/fsspec/implementations/tests/ftp_tls.py b/fsspec/implementations/tests/ftp_tls.py index c15c153fb..6d1359bfa 100644 --- a/fsspec/implementations/tests/ftp_tls.py +++ b/fsspec/implementations/tests/ftp_tls.py @@ -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() diff --git a/fsspec/implementations/tests/test_ftp.py b/fsspec/implementations/tests/test_ftp.py index 98561489b..ccac390d3 100644 --- a/fsspec/implementations/tests/test_ftp.py +++ b/fsspec/implementations/tests/test_ftp.py @@ -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, ) @@ -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()