From 7c6e45f5491789d2491594aec4a5c58af6b67b9f Mon Sep 17 00:00:00 2001 From: Peter Hamilton Date: Thu, 27 Jul 2017 11:38:07 -0400 Subject: [PATCH] Fix bug generating detached instance errors in server tests This patch fixes a bug that generates intermittent sqlalchemy DetachedInstanceErrors during the KMIP server engine unit test execution. Specifically, this fix disables instance expiration on commit for the sqlalchemy sessions used throughout the unit tests, allowing access to instance attributes even if the instance is detached from a session. Fixes #312 --- kmip/tests/unit/services/server/test_engine.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kmip/tests/unit/services/server/test_engine.py b/kmip/tests/unit/services/server/test_engine.py index d2aea30..c5da620 100644 --- a/kmip/tests/unit/services/server/test_engine.py +++ b/kmip/tests/unit/services/server/test_engine.py @@ -83,7 +83,8 @@ class TestKmipEngine(testtools.TestCase): ) sqltypes.Base.metadata.create_all(self.engine) self.session_factory = sqlalchemy.orm.sessionmaker( - bind=self.engine + bind=self.engine, + expire_on_commit=False ) self.temp_dir = tempfile.mkdtemp()