From: Nir Soffer nsoffer@redhat.com
tox make it easy to run python tests with multiple versions of python.
To run all python tests:
$ tox
This command: - sets environment variables for the test, without modifying your shell - creates python virtual environment for python 2.7 and python 3.6 if needed. - installs the test dependencies in the virtual environment without modifying system python. - builds wdmd, sanlock and the python module - runs the tests with both python versions
Note: python 3.6 fails now because the python module does not compile yet on python 3.
To run only the python 2.7 tests:
$ tox -e py27
README.dev was simplified; there is not need now to install pytest, run make, or set environment variables.
pytest.ini was merged into tox.ini.
Signed-off-by: Nir Soffer nsoffer@redhat.com --- README.dev | 27 +++++++++++++++------------ pytest.ini | 7 ------- tox.ini | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 19 deletions(-) delete mode 100644 pytest.ini create mode 100644 tox.ini
diff --git a/README.dev b/README.dev index 04fbb02..3519993 100644 --- a/README.dev +++ b/README.dev @@ -1,23 +1,26 @@ How to test sanlock ===================
-To run the python based tests, you need pytest. The best way to install a +To run the python based tests, you need tox. The best way to install a recent version is to use pip:
- $ pip install pytest + $ pip install tox
-Before running the tests, you need to build wdmd, sanlock, and sanlock -python bindings: +To run the tests with python 2.7 and 3.6:
- $ make -C wdmd - $ make -C src - $ make -C python inplace + $ tox
-Setup the environment for testing sanlock running sanlcok from source as -current user: +Note: python 3.6 tests will fail now, since sanlock extension module needs +changes to compile on python 3.
- $ source tests/env.sh +To run only python 2.7:
-To run the tests: + $ tox -e py27
- $ pytest +To run only test from some modules: + + $ tox tests/daemon_test.py + +To run only tests matching the substring "foo": + + $ tox -- -k foo diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index bb17bd5..0000000 --- a/pytest.ini +++ /dev/null @@ -1,7 +0,0 @@ -[pytest] -# Notes: -# --basetemp: we must use /var/tmp as sanlock uses direct I/O. -# -vv: increasing verbosify twice shows more detailed failures tracebacks. -# -rxs: show extra test summary: (s)skipped, (x)failed -# --durations: show slowest test duration -addopts = -rxs -vv --basetemp=/var/tmp/sanlock --durations=10 diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..ae9c8a7 --- /dev/null +++ b/tox.ini @@ -0,0 +1,34 @@ +# Tox (http://tox.testrun.org/) 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 = py27,py36 +skipsdist = True +skip_missing_interpreters = True + +[testenv] +passenv = USER +setenv = + LD_LIBRARY_PATH={env:PWD}/wdmd:{env:PWD}/src + SANLOCK_PRIVILEGED=0 + SANLOCK_RUN_DIR=/tmp/sanlock + PYTHONPATH={env:PWD}/python +sitepackages = True +whitelist_externals = make +deps = + pytest==4.0 +commands = + make -C wdmd + make -C src + make -C python inplace + pytest {posargs} + +[pytest] +# Notes: +# --basetemp: we must use /var/tmp as sanlock uses direct I/O. +# -vv: increasing verbosify twice shows more detailed failures tracebacks. +# -rxs: show extra test summary: (s)skipped, (x)failed +# --durations: show slowest test duration +addopts = -rxs -vv --basetemp=/var/tmp/sanlock --durations=10
sanlock-devel@lists.fedorahosted.org