diff --git a/heat/tests/utils.py b/heat/tests/utils.py index cf3e383f8c..19fc1a06fc 100644 --- a/heat/tests/utils.py +++ b/heat/tests/utils.py @@ -220,15 +220,19 @@ class JsonRepr(object): class ForeignKeyConstraintFixture(fixtures.Fixture): - def __init__(self, sqlite_fk=True): - self.enable_fkc = sqlite_fk + + def __init__(self): + self.engine = get_engine() def _setUp(self): - new_context = db_api.db_context.make_new_manager() - new_context.configure(sqlite_fk=self.enable_fkc) + if self.engine.name == 'sqlite': + self.engine.execute("PRAGMA foreign_keys=ON") - self.useFixture(fixtures.MockPatchObject(db_api, '_facade', None)) - self.addCleanup(db_api.db_context.patch_factory(new_context._factory)) + def disable_fks(): + with self.engine.connect() as conn: + conn.connection.rollback() + conn.execute("PRAGMA foreign_keys=OFF") + self.addCleanup(disable_fks) class AnyInstance(object): diff --git a/tox.ini b/tox.ini index 10fc106061..662ebcac7f 100644 --- a/tox.ini +++ b/tox.ini @@ -9,7 +9,6 @@ basepython = python3 setenv = VIRTUAL_ENV={envdir} PYTHONWARNINGS=default::DeprecationWarning OS_TEST_PATH=heat/tests -install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} {opts} {packages} usedevelop = True deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} -r{toxinidir}/requirements.txt @@ -59,6 +58,7 @@ allowlist_externals = rm deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} + -r{toxinidir}/requirements.txt -r{toxinidir}/doc/requirements.txt commands = rm -rf doc/build