Files
fm-orchestrator/tox.ini
Chenxiong Qi 630f7b4e18 Allow to run tests with PostgreSQL inside container
This patch introduces a new environment variable in order to allow running
tests with different database backend. This is useful particularly for running
tests inside container. With this change, it is possible run tests in following
combinations:

* Python 2 and SQLite
* Python 3 and SQLite
* Python 2 and PostgreSQL
* Python 3 and PostgreSQL

Package python-psycopg2 is installed in both Dockerfile-tests and
Dockerfile-tests-py3 in case of running tests with PostgreSQL.

A new script contrib/run-unittests.sh is added to make it easy to run tests. An
example:

    contrib/run-unittests.sh --py3 --with-pgsql

that runs tests with Python 3 and PostgreSQL.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-06-17 22:47:23 +08:00

57 lines
1.4 KiB
INI

# 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 = flake8, py27, py3
[flake8]
ignore = E731,W503
max-line-length = 100
exclude =
./.tox
./.git
./module_build_service/migrations
./build
./.env
[testenv]
usedevelop = true
sitepackages = true
# Allow to switch database backend for running tests.
passenv = DATABASE_URI
whitelist_externals =
flake8
py.test-3
deps = -r{toxinidir}/test-requirements.txt
commands =
py.test -v \
-W "ignore:Use .persist_selectable:DeprecationWarning" \
-W "ignore:The ConnectionEvents.dbapi_error() event is deprecated and will be removed in a future release. Please refer to the ConnectionEvents.handle_error() event.:DeprecationWarning" \
{posargs}
[testenv:coverage]
basepython = python2
deps =
{[testenv]deps}
coverage
commands =
coverage run --parallel-mode -m pytest
coverage combine
coverage report --omit=tests/*,.tox/*,/usr/* -m --skip-covered
[testenv:flake8]
basepython = python2
skip_install = true
deps = flake8
commands = flake8
[testenv:bandit]
basepython = python2
skip_install = true
deps = bandit
commands =
/bin/bash -c "bandit -r -ll $(find . -mindepth 1 -maxdepth 1 ! -name tests ! -name \.\* -type d -o -name \*.py)"
ignore_outcome = True