Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Alex Waygood <[email protected]>
  • Loading branch information
srittau and AlexWaygood authored Jul 23, 2024
1 parent 30c03b1 commit 817fe9f
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions src/test_typing_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
TYPING_3_13_0 = sys.version_info[:3] >= (3, 13, 0)

# 3.13.0.rc1 fixes a problem with @deprecated
TYPING_3_13_0_RC = sys.version_info[:3] >= (3, 13, 0) and sys.version_info[:4] != (3, 13, 0, 'beta')
TYPING_3_13_0_RC = sys.version_info[:3] >= (3, 13, 0, "candidate")

# https://github.com/python/cpython/pull/27017 was backported into some 3.9 and 3.10
# versions, but not all
Expand Down Expand Up @@ -875,30 +875,18 @@ async def coro(self):
pass

class DeprecatedCoroTests(BaseTestCase):
@skipUnless(TYPING_3_12_ONLY or TYPING_3_13_0_RC, "inspect.iscoroutinefunction works differently on Python < 3.12")
def test_inspect_py313(self):
self.assertFalse(inspect.iscoroutinefunction(func))
self.assertFalse(inspect.iscoroutinefunction(Cls.func))
self.assertTrue(inspect.iscoroutinefunction(coro))
self.assertTrue(inspect.iscoroutinefunction(Cls.coro))

def test_asyncio_iscoroutinefunction(self):
self.assertFalse(asyncio.coroutines.iscoroutinefunction(func))
self.assertFalse(asyncio.coroutines.iscoroutinefunction(Cls.func))
self.assertTrue(asyncio.coroutines.iscoroutinefunction(coro))
self.assertTrue(asyncio.coroutines.iscoroutinefunction(Cls.coro))

@skipIf(TYPING_3_12_0, "inspect.iscoroutinefunction works differently on Python 3.12+")
def test_inspect_py311(self):
# This doesn't work in Python < 3.12.
# self.assertTrue(inspect.iscoroutinefunction(func))
# self.assertTrue(inspect.iscoroutinefunction(Cls.func))
self.assertFalse(inspect.iscoroutinefunction(coro))
self.assertFalse(inspect.iscoroutinefunction(Cls.coro))

self.assertFalse(asyncio.coroutines.iscoroutinefunction(func))
self.assertFalse(asyncio.coroutines.iscoroutinefunction(Cls.func))
self.assertTrue(asyncio.coroutines.iscoroutinefunction(coro))
self.assertTrue(asyncio.coroutines.iscoroutinefunction(Cls.coro))
@skipUnless(TYPING_3_12_ONLY or TYPING_3_13_0_RC, "inspect.iscoroutinefunction works differently on Python < 3.12")
def test_inspect_iscoroutinefunction(self):
self.assertFalse(inspect.iscoroutinefunction(func))
self.assertFalse(inspect.iscoroutinefunction(Cls.func))
self.assertTrue(inspect.iscoroutinefunction(coro))
self.assertTrue(inspect.iscoroutinefunction(Cls.coro))


class AnyTests(BaseTestCase):
Expand Down

0 comments on commit 817fe9f

Please sign in to comment.