continuing for #10747, add a test asserting we dont get an
endless loop and get a clean ValueError instead when greenlet not
installed and async functions are used.
Fixes: #10747
Change-Id: I54dffe8577025e2ef3a59f5ca9ab7f4362d4d91f
(cherry picked from commit
35a0854cae1e23271963e7781c65495e9c84f872)
def asyncio(self):
return self.greenlet
+ @property
+ def no_greenlet(self):
+ def go(config):
+ try:
+ import greenlet # noqa: F401
+ except ImportError:
+ return True
+ else:
+ return False
+
+ return exclusions.only_if(go)
+
@property
def greenlet(self):
def go(config):
t.join()
is_true(run[0])
+
+
+class GracefulNoGreenletTest(fixtures.TestBase):
+ __requires__ = ("no_greenlet",)
+
+ def test_await_only_graceful(self):
+ async def async_fn():
+ pass
+
+ with expect_raises_message(
+ ValueError,
+ "the greenlet library is required to use this "
+ "function. No module named 'greenlet'",
+ ):
+ await_only(async_fn())