{"id":27964,"library":"mocksftp","title":"Mock SFTP Server for Testing","description":"Mocksftp (v1.0.1) provides a mock SFTP server for integration testing. It runs an in-process SFTP server backed by paramiko, enabling tests to exercise SFTP clients without a real SSH server. Low activity, no release schedule.","status":"active","version":"1.0.1","language":"python","source_language":"en","source_url":"https://github.com/LabD/python-mocksftp","tags":["testing","sftp","mock","paramiko","integration-testing"],"install":[{"cmd":"pip install mocksftp","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"SSH/SFTP protocol implementation","package":"paramiko","optional":false}],"imports":[{"note":"Hyphenated package name mocksftp, not underscore","wrong":"from mock_sftp import MockSFTPServer","symbol":"MockSFTPServer","correct":"from mocksftp import MockSFTPServer"}],"quickstart":{"code":"import os\nfrom mocksftp import MockSFTPServer\nimport paramiko\n\nwith MockSFTPServer() as server:\n    port = server.server_port\n    username = 'testuser'\n    password = 'testpass'\n    transport = paramiko.Transport(('localhost', port))\n    transport.connect(username=username, password=password)\n    sftp = paramiko.SFTPClient.from_transport(transport)\n    sftp.put('local.txt', 'remote.txt')\n    sftp.close()\n    transport.close()","lang":"python","description":"Basic usage: start mock SFTP server, connect and transfer file."},"warnings":[{"fix":"MockSFTPServer(use_pipe=False) when running on platforms with PF_LOCAL issues.","message":"MockSFTPServer uses PF_LOCAL sockets on some systems; set use_pipe=False to force TCP.","severity":"gotcha","affected_versions":"all"},{"fix":"pip install paramiko[gssapi] cryptography>=41.0","message":"From python 3.12+, paramiko may fail due to deprecation of Crypto. Ensure paramiko and cryptography are updated.","severity":"gotcha","affected_versions":"1.0.1"},{"fix":"Use the filesystem argument to set a persistent root directory if needed.","message":"MockSFTPServer does not persist files between sessions; each context creates a fresh temp directory.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"pip install mocksftp and use import mocksftp","cause":"Missing installation or wrong import name.","error":"ModuleNotFoundError: No module named 'mocksftp'"},{"fix":"Use MockSFTPServer inside a 'with' block, and access server_port from the context manager.","cause":"Server not started; the server_port is only available after entering the context.","error":"AttributeError: 'MockSFTPServer' object has no attribute 'server_port'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}