Every test gets its own db.

This commit is contained in:
Roland 2019-10-15 12:34:41 -06:00
parent 2e10a06a38
commit d9a48e2325
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93

View file

@ -1,4 +1,6 @@
import functools
import random
import string
import mock
import psycopg2
@ -7,8 +9,6 @@ from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT
from wrolpi.common import setup_relations
TESTING_DB_NAME = 'wrolpi_testing'
def test_db_wrapper(func):
"""
@ -25,6 +25,8 @@ def test_db_wrapper(func):
port=54321,
)
TESTING_DB_NAME = 'wrolpi_testing_' + ''.join(random.choices(string.ascii_lowercase, k=20))
# Set isolation level such that was can copy the schema of the "wrolpi" database for testing
with psycopg2.connect(dbname='postgres', **db_args) as db_conn:
db_conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)