FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.13] typing tests: remove some unnecessary uses of `exec()` (GH-119005) by miss-islington · Pull Request #119038 · python/cpython · GitHub

/ cpython Public
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
28 changes: 9 additions & 19 deletions Lib/test/test_typing.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -7060,24 +7060,16 @@ def test_iterator(self):
self.assertNotIsInstance(42, typing.Iterator)

def test_awaitable(self):
ns = {}
exec(
"async def foo() -> typing.Awaitable[int]:\n"
" return await AwaitableWrapper(42)\n",
globals(), ns)
foo = ns['foo']
async def foo() -> typing.Awaitable[int]:
return await AwaitableWrapper(42)
g = foo()
self.assertIsInstance(g, typing.Awaitable)
self.assertNotIsInstance(foo, typing.Awaitable)
g.send(None) # Run foo() till completion, to avoid warning.

def test_coroutine(self):
ns = {}
exec(
"async def foo():\n"
" return\n",
globals(), ns)
foo = ns['foo']
async def foo():
return
g = foo()
self.assertIsInstance(g, typing.Coroutine)
with self.assertRaises(TypeError):
Expand Down Expand Up @@ -7362,10 +7354,9 @@ def test_no_generator_instantiation(self):
typing.Generator[int, int, int]()

def test_async_generator(self):
ns = {}
exec("async def f():\n"
" yield 42\n", globals(), ns)
g = ns['f']()
async def f():
yield 42
g = f()
self.assertIsSubclass(type(g), typing.AsyncGenerator)

def test_no_async_generator_instantiation(self):
Expand Down Expand Up @@ -7452,9 +7443,8 @@ def asend(self, value):
def athrow(self, typ, val=None, tb=None):
pass

ns = {}
exec('async def g(): yield 0', globals(), ns)
g = ns['g']
async def g(): yield 0

self.assertIsSubclass(G, typing.AsyncGenerator)
self.assertIsSubclass(G, typing.AsyncIterable)
self.assertIsSubclass(G, collections.abc.AsyncGenerator)
Expand Down

Back | FazBrowse Home | New Git URL