A PyTest plugin which provides an FTP fixture for your tests
Project description
A PyTest plugin which provides an FTP fixture for your tests
Free software: MIT license
Documentation: https://pytest-localftpserver.readthedocs.io/en/latest/index.html
Attention!
As of version 1.0.0 the support for python 2.7 and 3.4 was dropped. If you need to support those versions you should pin the version to 0.6.0, i.e. add the following lines to your “requirements_dev.txt”:
# pytest_localftpserver==0.6.0 https://github.com/oz123/pytest-localftpserver/archive/v0.6.0.zip
Usage Quickstart:
This Plugin provides the fixtures ftpserver and ftpserver_TLS, which are threaded instances of a FTP server, with which you can upload files and test FTP functionality. It can be configured using the following environment variables:
Environment variable |
Usage |
---|---|
FTP_USER |
Username of the registered user. |
FTP_PASS |
Password of the registered user. |
FTP_PORT |
Port for the normal ftp server to run on. |
FTP_HOME |
Home folder (host system) of the registered user. |
FTP_FIXTURE_SCOPE |
Scope/lifetime of the fixture. |
FTP_PORT_TLS |
Port for the TLS ftp server to run on. |
FTP_HOME_TLS |
Home folder (host system) of the registered user, used by the TLS ftp server. |
FTP_CERTFILE |
Certificate (host system) to be used by the TLS ftp server. |
See the tests directory or the documentation for examples.
You can either set environment variables on a system level or use tools such as pytest-env or tox, to change the default settings of this plugin. Sample config for pytest-cov:
$ cat pytest.ini [pytest] env = FTP_USER=benz FTP_PASS=erni1 FTP_HOME = /home/ftp_test FTP_PORT=31175 FTP_FIXTURE_SCOPE=function # only affects ftpserver_TLS FTP_PORT_TLS = 31176 FTP_HOME_TLS = /home/ftp_test_TLS FTP_CERTFILE = ./tests/test_keycert.pem
Sample config for Tox:
$ cat tox.ini [tox] envlist = py{36,37,38,39,310} [testenv] setenv = FTP_USER=benz FTP_PASS=erni1 FTP_HOME = {envtmpdir} FTP_PORT=31175 FTP_FIXTURE_SCOPE=function # only affects ftpserver_TLS FTP_PORT_TLS = 31176 FTP_HOME_TLS = /home/ftp_test_TLS FTP_CERTFILE = {toxinidir}/tests/test_keycert.pem commands = pytest tests
Credits
This package was inspired by, https://pypi-hypernode.com/project/pytest-localserver/ made by Sebastian Rahlf, which lacks an FTP server.
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pytest_localftpserver-1.3.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee54a43c4782acefeb608596b5e8090ebaa7aa1e418855c72bb6da4dd832d3f3 |
|
MD5 | 10e8949b493484d231173eb8ec7c0488 |
|
BLAKE2b-256 | 83bc51fd0a05b8f4652d842489f142cf1d3a8f67e8412597ce1b427273984fc7 |
Hashes for pytest_localftpserver-1.3.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82501ad85a1e328735c3a9a1b713bfaf7caddf992c8824949063abddda0829bb |
|
MD5 | 522860355e1910c03552294d7610b4b2 |
|
BLAKE2b-256 | 1d391c219128f8c8a77d71e7391ed648c5b884bda7748de176290d6f0773cf3c |