+from asyncio import current_task
+
import sqlalchemy as sa
from sqlalchemy import func
from sqlalchemy import select
from sqlalchemy import testing
from sqlalchemy.ext.asyncio import async_scoped_session
from sqlalchemy.ext.asyncio import AsyncSession as _AsyncSession
+from sqlalchemy.orm import sessionmaker
from sqlalchemy.testing import async_test
from sqlalchemy.testing import eq_
from sqlalchemy.testing import is_
await AsyncSession.delete(u1)
await AsyncSession.flush()
eq_(await conn.scalar(stmt), 0)
+
+ def test_attributes(self, async_engine):
+ expected = [
+ name
+ for cls in _AsyncSession.mro()
+ for name in vars(cls)
+ if not name.startswith("_")
+ ]
+
+ ignore_list = {
+ "dispatch",
+ "sync_session_class",
+ "run_sync",
+ "get_transaction",
+ "get_nested_transaction",
+ "in_transaction",
+ "in_nested_transaction",
+ }
+
+ SM = async_scoped_session(
+ sessionmaker(async_engine, class_=_AsyncSession), current_task
+ )
+
+ missing = [
+ name
+ for name in expected
+ if not hasattr(SM, name) and name not in ignore_list
+ ]
+ eq_(missing, [])
ss = scoped_session(sessionmaker(testing.db, class_=MySession))
is_(ss.get_bind(), testing.db)
+
+ def test_attributes(self):
+ expected = [
+ name
+ for cls in Session.mro()
+ for name in vars(cls)
+ if not name.startswith("_")
+ ]
+
+ ignore_list = {
+ "connection_callable",
+ "transaction",
+ "in_transaction",
+ "in_nested_transaction",
+ "get_transaction",
+ "get_nested_transaction",
+ "prepare",
+ "invalidate",
+ "bind_mapper",
+ "bind_table",
+ "enable_relationship_loading",
+ "dispatch",
+ }
+
+ SM = scoped_session(sa.orm.sessionmaker(testing.db))
+
+ missing = [
+ name
+ for name in expected
+ if not hasattr(SM, name) and name not in ignore_list
+ ]
+ eq_(missing, [])