|
38 | 38 | from sqlalchemy.orm import mapper |
39 | 39 | from sqlalchemy.orm import relation |
40 | 40 | from sqlalchemy.orm import relationship |
| 41 | +from sqlalchemy.orm import scoped_session |
41 | 42 | from sqlalchemy.orm import Session |
| 43 | +from sqlalchemy.orm import sessionmaker |
42 | 44 | from sqlalchemy.orm import subqueryload |
43 | 45 | from sqlalchemy.orm import synonym |
44 | 46 | from sqlalchemy.orm import undefer |
|
54 | 56 | from sqlalchemy.testing import AssertsCompiledSQL |
55 | 57 | from sqlalchemy.testing import eq_ |
56 | 58 | from sqlalchemy.testing import eq_ignore_whitespace |
| 59 | +from sqlalchemy.testing import expect_deprecated |
57 | 60 | from sqlalchemy.testing import fixtures |
58 | 61 | from sqlalchemy.testing import is_ |
59 | 62 | from sqlalchemy.testing import is_true |
@@ -5475,3 +5478,23 @@ def test_bind_base_table_concrete_sub_class(self): |
5475 | 5478 | session = self._fixture({self.tables.base_table: base_class_bind}) |
5476 | 5479 |
|
5477 | 5480 | is_(session.get_bind(self.classes.ConcreteSubClass), testing.db) |
| 5481 | + |
| 5482 | + |
| 5483 | +class DeprecationScopedSessionTest(fixtures.MappedTest): |
| 5484 | + def test_config_errors(self): |
| 5485 | + sm = sessionmaker() |
| 5486 | + |
| 5487 | + def go(): |
| 5488 | + s = sm() |
| 5489 | + s._is_asyncio = True |
| 5490 | + return s |
| 5491 | + |
| 5492 | + Session = scoped_session(go) |
| 5493 | + |
| 5494 | + with expect_deprecated( |
| 5495 | + "Using `scoped_session` with asyncio is deprecated and " |
| 5496 | + "will raise an error in a future version. " |
| 5497 | + "Please use `async_scoped_session` instead." |
| 5498 | + ): |
| 5499 | + Session() |
| 5500 | + Session.remove() |
0 commit comments