OpenKMIP / PyKMIP

A Python implementation of the KMIP specification.
Apache License 2.0
272 stars 134 forks source link

Multiple tests failed one on particular filter construct. #649

Closed mcepl closed 3 years ago

mcepl commented 3 years ago

When running the test suite for PyKMIP (using platform linux -- Python 3.6.13, pytest-6.2.4, py-1.10.0, pluggy-0.13.1, SQLAlchemy-1.4.15-207.2, full log with all details) 46 tests fail on this construct:

        get_obj = session.query(OpaqueObject).filter(
            ManagedObject.unique_identifier == obj.unique_identifier
            ).one()

with the error: sqlalchemy.orm.exc.DetachedInstanceError: Instance <OpaqueObject at 0x7f3da8148048> is not bound to a Session; attribute refresh operation cannot proceed (Background on this error at: http://sqlalche.me/e/14/bhk3). I was looking at the suggested web page, I dimly understand the issue, but I cannot understand how it applies here. Is it ManagedObject which is the unadjusted one, or obj?

tipabu commented 3 years ago

FWIW, I've seen similar issues and tracked it down to the version of SQLAlchemy -- I can get passing tests as late as SQLAlchemy==1.3.24, but with SQLAlchemy==1.4.0 and later I too get 46 failures.

It seems to be related to some tests re-initializing a Session post-commit(); at any rate, adding an expire_on_commit=False when calling sessionmaker() seems to solve it in most cases.

PeterHamilton commented 3 years ago

@mcepl @tipabu Thanks for filing this issue, and the associated pull request, and my apologies for being so tardy on taking a look at this. I don't spend as much time on PyKMIP nowadays as I would like.

I'll give the pull request a review within the next day or so.