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
This commit is contained in:
Peter Hamilton 2017-07-27 11:38:07 -04:00
parent f86134878b
commit 7c6e45f549
1 changed files with 2 additions and 1 deletions

View File

@ -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()