Skip to main content

A PyTest plugin which provides an FTP fixture for your tests

Project description

PyTest FTP Server

https://img.shields.io/pypi/v/pytest_localftpserver.svg https://camo.githubusercontent.com/89b9f56d30241e30f546daf9f43653f08e920f16/68747470733a2f2f696d672e736869656c64732e696f2f636f6e64612f766e2f636f6e64612d666f7267652f7079746573742d6c6f63616c6674707365727665722e737667 https://img.shields.io/pypi/pyversions/pytest_localftpserver.svg https://github.com/oz123/pytest-localftpserver/workflows/Tests/badge.svg Documentation Status Updates Coverage

A PyTest plugin which provides an FTP fixture for your tests

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.org/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.

History

1.0.1 (2019-12-10)

  • Include the certificate in the source package

  • Use a bigger certificate

1.0.0 (2019-09-05)

  • Dropped support for Python 2.7 and 3.4

0.6.0 - released as tag only

  • Added fixture scope configuration.

  • Added ftpserver_TLS as TLS version of the fixture.

0.5.0 (2018-12-04)

  • Added support for Windows.

  • Added hightlevel interface.

0.1.0 (2016-12-09)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_localftpserver-1.1.3.tar.gz (44.5 kB view details)

Uploaded Source

Built Distribution

pytest_localftpserver-1.1.3-py2.py3-none-any.whl (21.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pytest_localftpserver-1.1.3.tar.gz.

File metadata

  • Download URL: pytest_localftpserver-1.1.3.tar.gz
  • Upload date:
  • Size: 44.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

File hashes

Hashes for pytest_localftpserver-1.1.3.tar.gz
Algorithm Hash digest
SHA256 570435051df9c5f20a3ab2083b4cb7248f1af89788d514fb73c53192e9bc67d4
MD5 cef114fe5631f8f24a08de80279a5fea
BLAKE2b-256 93f50b9933e45ca4813d73ca9a2892d990d08e4677d09a617c0a241e2a8af058

See more details on using hashes here.

File details

Details for the file pytest_localftpserver-1.1.3-py2.py3-none-any.whl.

File metadata

  • Download URL: pytest_localftpserver-1.1.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 21.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

File hashes

Hashes for pytest_localftpserver-1.1.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8cfea543ff3e966fbffc2b6055829d9f7342f64500c0c35adba90eb1870a6bdd
MD5 f421d23f0edce62bd65c81a84c713eb2
BLAKE2b-256 0cff2827eba425ef51894792303f7ae1cc64333d79cc27f7c79a5acdd0d2540e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page