From 99324f5c1bea4d48279a9bae13d02a9add52f710 Mon Sep 17 00:00:00 2001 From: Hervé Beraud Date: Jan 18 2019 14:07:21 +0000 Subject: Refactor testing by introducing tox. Since we have propose to refactor the project release management by using pbr we now propose with this commit to refactor testing by using tox[1]. Why using tox? tox introduce virtualenv for testing and allow to test your project with multiple version of python in the same time. Also tox is a standard tools in python community and made the testing more straightforward for your contributors and maintainers. This commit introduce: - introduce requirements file for tests dependancies; - remove PEP 518 since pbr was introduced and your pyproject.toml was incompatible with tox; - improve hacking doc by explain to your contributors how to test theirs changes. Using it: - install tox (pip install tox); - launch tests (tox) tox[1] allow simplify python testing by introducing: - virtualenv; - specific targets; - cross testing; - integrated with many CI platforms. In order merge this pull request before => https://pagure.io/python-daemon/pull-request/23 [1] https://tox.readthedocs.io/en/latest/ Co-authored-by: Hobbestigrou hobbestigrou@erakis.eu --- diff --git a/doc/hacking.txt b/doc/hacking.txt index 8f73b12..97e71d8 100644 --- a/doc/hacking.txt +++ b/doc/hacking.txt @@ -192,6 +192,14 @@ changes to existing code, will only be considered for inclusion in the development tree when accompanied by corresponding additions or changes to the unit tests. +To launch unit test using the following commands:: + + $ tox + +You can also check specific environment by using:: + + $ tox -e py37 + Test-driven development ----------------------- diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index b396dd7..0000000 --- a/pyproject.toml +++ /dev/null @@ -1,16 +0,0 @@ -# pyproject.toml -# Build system requirements for Python code in this code base. -# Documentation: . - -[build-system] - -# Minimum requirements for the build system. -requires = ["setuptools", "wheel", "docutils"] - - -# Local-variables: -# coding: utf-8 -# mode: conf -# mode: toml -# End: -# vim: fileencoding=utf-8 filetype=toml : diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 0000000..30394da --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,5 @@ +unittest2>=0.5.1 +testtools +testscenarios>=0.4 +mock>=1.3 +docutils diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..00001ca --- /dev/null +++ b/tox.ini @@ -0,0 +1,13 @@ +# tox (https://tox.readthedocs.io/) is a tool for running tests +# in multiple virtualenvs. This configuration file will run the +# test suite on all supported python versions. To use it, "pip install tox" +# and then run "tox" from this directory. + +[tox] +envlist = py35, py36, py37, pep8, docs + +[testenv] +deps = -r{toxinidir}/test-requirements.txt + +commands = + python -m unittest discover