pytest-sftpserver
py.test plugin to locally test sftp server connections.
What it is and what it does
pytest-sftpserver is a pytest plugin that injects an SFTP server fixture into your tests. Rather than serving files from disk, it serves content directly from Python objects—dictionaries representing directory structures and file contents. This lets you test SFTP client code (code that connects to and downloads from SFTP servers) without spinning up a real external server or managing temporary files.
The plugin depends on paramiko for SFTP protocol handling and six for Python 2/3 compatibility. It's designed for unit and integration testing of SFTP client functions. The package has been dormant since 2019 but remains functional; it targets Python 2.7 and 3.5–3.7 according to its classifiers.
Use it for:
- Unit test an SFTP client function by mocking server responses with in-memory file structures instead of real files.
- Integration test a data pipeline that fetches files from SFTP without requiring a live SFTP server in CI/CD.
- Test error handling in SFTP client code by simulating missing files or permission issues via the mock server.
- Verify SFTP connection logic and authentication flows in isolation without external infrastructure.
- Test directory traversal and recursive file operations against a controlled mock SFTP environment.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A pytest plugin that provides a fixture for testing SFTP client code against an in-memory mock SFTP server without needing an external server.
Yes, if you need to test SFTP client code and want to avoid external server setup. The low install friction, permissive license, and zero known vulnerabilities make it a straightforward choice. However, note that the package is dormant (last release 2019) and classifiers indicate support only through Python 3.7—verify compatibility with your target Python version before adopting.
Install
pytest-sftpserver on PyPI
pip
pip install pytest-sftpserveruv
uv add pytest-sftpserverpoetry
poetry add pytest-sftpserverInstalling pytest-sftpserver
Before you install
Low install friction with only two runtime dependencies (paramiko and six). The package is dormant—last release was 2019-09-16 and last commit 2024-03-20—so maintenance is minimal but the codebase remains archived and functional.
License in practice
MIT License (permissive) means you can use, modify, and distribute this package freely in both open-source and commercial projects with minimal restrictions.
Quickstart
pip install pytest-sftpserver
import pytest
from pytest_sftpserver import sftpserver
def test_sftp_fetch(sftpserver):
with sftpserver.serve_content({'a_dir': {'somefile.txt': 'File content'}}):
# Test your SFTP client code here
pass
Verify before relying
- Whether the package works with Python versions beyond 3.7 (classifiers list only 2.7, 3.5–3.7, but last commit is 2024)
- Whether paramiko and six versions have known compatibility issues with modern Python environments
Package facts
| License | MIT License (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — paramiko, six |
| Maintenance | dormant — 2,524 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,067,149/month — #4,411 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytest_sftpserver-1.3.0-py2.py3-none-any.whl
Keywords: py.test, pytest, plugin, server, local, sftp, localhost
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
mocksftpProvides an in-process SFTP server for testing…
permissive · top 15,000 on PyPI
pytest-localftpserverProvides pytest fixtures for running local FTP…
permissive · top 15,000 on PyPI
sftpserverProvides a simple single-threaded SFTP server…
permissive · top 15,000 on PyPI
pytest-localserverProvides pytest fixtures that spin up local…
permissive · top 15,000 on PyPI
mock-ssh-serverProvides a Python context manager that runs an…
permissive · top 15,000 on PyPI
pytest-stubA pytest plugin that replaces package, module,…
permissive · top 15,000 on PyPI
pytest-mockProvides a pytest fixture that wraps the mock…
permissive · top 1,000 on PyPI
pytest-httpbinProvides a pytest fixture that runs a local…
permissive · top 15,000 on PyPI
pytest-base-urlA pytest plugin that injects a configurable…
copyleft · top 5,000 on PyPI
pytest-mock-resourcesProvides pytest fixtures that spin up real…
permissive · top 15,000 on PyPI