async def test_async_object_session_del(self, async_engine): User = self.classes.User s1 = AsyncSession(async_engine) u1 = await s1.get(User, 7) is_(async_object_session(u1), s1) await s1.rollback() del s1 is_(async_object_session(u1), None)
async def test_async_object_session_custom(self, async_engine): User = self.classes.User class MyCustomAsync(AsyncSession): pass s1 = MyCustomAsync(async_engine) u1 = await s1.get(User, 7) assert isinstance(async_object_session(u1), MyCustomAsync)
async def test_async_object_session(self, async_engine): User = self.classes.User s1 = AsyncSession(async_engine) s2 = AsyncSession(async_engine) u1 = await s1.get(User, 7) u2 = User(name="n1") s2.add(u2) u3 = User(name="n2") is_(async_object_session(u1), s1) is_(async_object_session(u2), s2) is_(async_object_session(u3), None) await s2.close() is_(async_object_session(u2), None)