pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/a9328e2b6ee05c186dcc552feb92b862b4a574df

241e157469407.css" /> typing tests: remove some unnecessary uses of `exec()` (#119005) · python/cpython@a9328e2 · GitHub
Skip to content

Commit a9328e2

Browse files
authored
typing tests: remove some unnecessary uses of exec() (#119005)
1 parent 331d385 commit a9328e2

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

Lib/test/test_typing.py

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7060,24 +7060,16 @@ def test_iterator(self):
70607060
self.assertNotIsInstance(42, typing.Iterator)
70617061

70627062
def test_awaitable(self):
7063-
ns = {}
7064-
exec(
7065-
"async def foo() -> typing.Awaitable[int]:\n"
7066-
" return await AwaitableWrapper(42)\n",
7067-
globals(), ns)
7068-
foo = ns['foo']
7063+
async def foo() -> typing.Awaitable[int]:
7064+
return await AwaitableWrapper(42)
70697065
g = foo()
70707066
self.assertIsInstance(g, typing.Awaitable)
70717067
self.assertNotIsInstance(foo, typing.Awaitable)
70727068
g.send(None) # Run foo() till completion, to avoid warning.
70737069

70747070
def test_coroutine(self):
7075-
ns = {}
7076-
exec(
7077-
"async def foo():\n"
7078-
" return\n",
7079-
globals(), ns)
7080-
foo = ns['foo']
7071+
async def foo():
7072+
return
70817073
g = foo()
70827074
self.assertIsInstance(g, typing.Coroutine)
70837075
with self.assertRaises(TypeError):
@@ -7352,10 +7344,9 @@ def test_no_generator_instantiation(self):
73527344
typing.Generator[int, int, int]()
73537345

73547346
def test_async_generator(self):
7355-
ns = {}
7356-
exec("async def f():\n"
7357-
" yield 42\n", globals(), ns)
7358-
g = ns['f']()
7347+
async def f():
7348+
yield 42
7349+
g = f()
73597350
self.assertIsSubclass(type(g), typing.AsyncGenerator)
73607351

73617352
def test_no_async_generator_instantiation(self):
@@ -7442,9 +7433,8 @@ def asend(self, value):
74427433
def athrow(self, typ, val=None, tb=None):
74437434
pass
74447435

7445-
ns = {}
7446-
exec('async def g(): yield 0', globals(), ns)
7447-
g = ns['g']
7436+
async def g(): yield 0
7437+
74487438
self.assertIsSubclass(G, typing.AsyncGenerator)
74497439
self.assertIsSubclass(G, typing.AsyncIterable)
74507440
self.assertIsSubclass(G, collections.abc.AsyncGenerator)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy