summaryrefslogtreecommitdiff
path: root/test/orm/test_dynamic.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/orm/test_dynamic.py')
-rw-r--r--test/orm/test_dynamic.py27
1 files changed, 18 insertions, 9 deletions
diff --git a/test/orm/test_dynamic.py b/test/orm/test_dynamic.py
index 94ecf4ee2..1ca1bec03 100644
--- a/test/orm/test_dynamic.py
+++ b/test/orm/test_dynamic.py
@@ -2,6 +2,7 @@ from sqlalchemy import cast
from sqlalchemy import desc
from sqlalchemy import exc
from sqlalchemy import func
+from sqlalchemy import inspect
from sqlalchemy import Integer
from sqlalchemy import select
from sqlalchemy import testing
@@ -969,17 +970,25 @@ class HistoryTest(_DynamicFixture, _fixtures.FixtureTest):
elif isinstance(obj, self.classes.Order):
attrname = "items"
- eq_(attributes.get_history(obj, attrname), compare)
+ sess = inspect(obj).session
- if compare_passive is None:
- compare_passive = compare
+ if sess:
+ sess.autoflush = False
+ try:
+ eq_(attributes.get_history(obj, attrname), compare)
- eq_(
- attributes.get_history(
- obj, attrname, attributes.LOAD_AGAINST_COMMITTED
- ),
- compare_passive,
- )
+ if compare_passive is None:
+ compare_passive = compare
+
+ eq_(
+ attributes.get_history(
+ obj, attrname, attributes.LOAD_AGAINST_COMMITTED
+ ),
+ compare_passive,
+ )
+ finally:
+ if sess:
+ sess.autoflush = True
def test_append_transient(self):
u1, a1 = self._transient_fixture()