From 77c133cc0ff0803f116ababc67ec8915389fb344 Mon Sep 17 00:00:00 2001 From: Chenxiong Qi Date: Aug 29 2018 08:53:01 +0000 Subject: Refine test runner for py26 Dependent tools to run tests do not support Python 2.6 recently, like tox, that causes `tox -e py26` fails to create a virtual environment with python2.6 interpreter. This patch uses a Makefile to create a Python 2.6 environment with virtualenv manually and to organize steps to run tests with Python 2.6 and other Python versions in only one command `make test`. Tests against py26 could be ignored by setting environment variable IGNORE_PY26. Signed-off-by: Chenxiong Qi --- diff --git a/.gitignore b/.gitignore index 7dad08e..63b0fcc 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ tags htmlcov/ /.eggs/ .env/ +.py26env/ doc/build/ doc/source/cli.rst diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f0fc722 --- /dev/null +++ b/Makefile @@ -0,0 +1,24 @@ +ifdef IGNORE_PY26 + default_targets=detox +else + default_targets=py26-test detox +endif + +test: $(default_targets) +.PHONY: test + +py26-test: + @virtualenv --python=python2.6 .py26env + @.py26env/bin/pip install tox + @.py26env/bin/tox -e py26 +.PHONY: py26-test + +detox: + @detox -e py27,py36,py37,flake8 +.PHONY: detox + +tox: + @python3 -m venv .env + @.env/bin/pip install tox + @.env/bin/tox -e py27,py36,py37,flake8 +.PHONY: tox diff --git a/README.rst b/README.rst index 8f18aa8..1575795 100644 --- a/README.rst +++ b/README.rst @@ -74,20 +74,17 @@ Certificate of Origin`_ for details. Run Tests --------- -Before make a pull request, ensure local changes pass all test cases. There -are two choices to run tests. +Before make a pull request, ensure local changes pass all test cases. -* Run tests in parallel with ``detox``. Newer version of ``detox`` does not - support ``py26``. You can run rest of test environments:: +Before run tests, install these packages:: - detox -e py27,py36,py37,flake8 + sudo dnf install python26 python37 detox python2-virtualenv -* Run tests inside a Python environment with ``tox``:: +To run tests simply, ``make test``. - python3 -m venv env - source env/bin/activate - pip install tox - tox +By default, target ``test`` runs tests with all supported Python versions. +However, if you look into ``Makefile``, there is still a target ``tox`` that +allows developer to run tests with test environments one by one. More Information ================ diff --git a/tox.ini b/tox.ini index a23eabe..707c7c3 100644 --- a/tox.ini +++ b/tox.ini @@ -12,9 +12,12 @@ setenv= PYCURL_SSL_LIBRARY=openssl [testenv:py26] -commands = - pip install -I "setuptools<37.0.0" "wheel<0.30.0" unittest2 - {[testenv]commands} +deps = + # Requirement path: koji -> pyOpenSSL + # Since this version, Python 2.6 support has been dropped. + pyOpenSSL<18.0.0 + unittest2 + {[testenv]deps} [testenv:flake8] basepython = python3