summaryrefslogtreecommitdiff
path: root/oslo_db/tests
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2018-06-12 13:26:39 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2018-07-02 18:02:24 -0400
commitdf6bf3401266f42271627c1e408f87c71a06cef7 (patch)
treefd0fb9c69dee834125ba98ebf21831c84bf25bc8 /oslo_db/tests
parent4c70002578d8ea109a7d0889ab53b9c20bae6ed4 (diff)
downloadoslo-db-df6bf3401266f42271627c1e408f87c71a06cef7.tar.gz
Rename enginefacade.async to enginefacade.async_
Python 3.7 now makes "async" a keyword, so deprecate the "async" name and replace with "async_". Additionally, use attribute name access only in order to implement and test "async" as it won't work under Python 3.7. Closes-Bug: #1775866 Change-Id: Ifb2c59c2cfbd615b04570b31fcfe868f4ffea3c6
Diffstat (limited to 'oslo_db/tests')
-rw-r--r--oslo_db/tests/sqlalchemy/test_enginefacade.py31
1 files changed, 26 insertions, 5 deletions
diff --git a/oslo_db/tests/sqlalchemy/test_enginefacade.py b/oslo_db/tests/sqlalchemy/test_enginefacade.py
index ced9483..cab7547 100644
--- a/oslo_db/tests/sqlalchemy/test_enginefacade.py
+++ b/oslo_db/tests/sqlalchemy/test_enginefacade.py
@@ -15,6 +15,7 @@ import contextlib
import copy
import fixtures
import pickle
+import sys
import warnings
import mock
@@ -607,7 +608,7 @@ class MockFacadeTest(oslo_test_base.BaseTestCase):
def test_async_on_writer_raises(self):
exc = self.assertRaises(
- TypeError, getattr, enginefacade.writer, "async"
+ TypeError, getattr, enginefacade.writer, "async_"
)
self.assertEqual(
"Setting async on a WRITER makes no sense",
@@ -626,7 +627,7 @@ class MockFacadeTest(oslo_test_base.BaseTestCase):
def test_reader_nested_in_async_reader_raises(self):
context = oslo_context.RequestContext()
- @enginefacade.reader.async
+ @enginefacade.reader.async_
def go1(context):
context.session.execute("test1")
go2(context)
@@ -647,7 +648,7 @@ class MockFacadeTest(oslo_test_base.BaseTestCase):
def test_reader_allow_async_nested_in_async_reader(self):
context = oslo_context.RequestContext()
- @enginefacade.reader.async
+ @enginefacade.reader.async_
def go1(context):
context.session.execute("test1")
go2(context)
@@ -701,7 +702,7 @@ class MockFacadeTest(oslo_test_base.BaseTestCase):
def test_writer_nested_in_async_reader_raises(self):
context = oslo_context.RequestContext()
- @enginefacade.reader.async
+ @enginefacade.reader.async_
def go1(context):
context.session.execute("test1")
go2(context)
@@ -741,10 +742,30 @@ class MockFacadeTest(oslo_test_base.BaseTestCase):
with self._assert_writer_session(makers) as session:
session.execute("test2")
+ def test_deprecated_async_reader_name(self):
+ if sys.version_info >= (3, 7):
+ self.skipTest("Test only runs on Python < 3.7")
+
+ context = oslo_context.RequestContext()
+
+ old = getattr(enginefacade.reader, "async")
+
+ @old
+ def go1(context):
+ context.session.execute("test1")
+
+ go1(context)
+
+ with self._assert_engines() as engines:
+ with self._assert_makers(engines) as makers:
+ with self._assert_async_reader_session(
+ makers, assert_calls=False) as session:
+ session.execute("test1")
+
def test_async_reader_then_reader_ok(self):
context = oslo_context.RequestContext()
- @enginefacade.reader.async
+ @enginefacade.reader.async_
def go1(context):
context.session.execute("test1")