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>
This commit is contained in:
Chenxiong Qi
2019-06-11 15:27:06 +08:00
parent 5794c4375d
commit 630f7b4e18
8 changed files with 111 additions and 18 deletions

View File

@@ -19,6 +19,8 @@ exclude =
[testenv]
usedevelop = true
sitepackages = true
# Allow to switch database backend for running tests.
passenv = DATABASE_URI
whitelist_externals =
flake8
py.test-3