Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
eca18aac
Kaydet (Commit)
eca18aac
authored
May 21, 2019
tarafından
Yury Selivanov
Kaydeden (comit)
Ned Deily
May 21, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-34616: Fix code style and unbreak buildbots (GH-13473)
See also PR GH-13148.
üst
7abf8c60
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
18 deletions
+20
-18
test_builtin.py
Lib/test/test_builtin.py
+20
-18
No files found.
Lib/test/test_builtin.py
Dosyayı görüntüle @
eca18aac
...
@@ -367,10 +367,10 @@ class BuiltinTest(unittest.TestCase):
...
@@ -367,10 +367,10 @@ class BuiltinTest(unittest.TestCase):
def
test_compile_top_level_await
(
self
):
def
test_compile_top_level_await
(
self
):
"""Test whether code some top level await can be compiled.
"""Test whether code some top level await can be compiled.
Make sure it compiles only with the PyCF_ALLOW_TOP_LEVEL_AWAIT flag
set,
Make sure it compiles only with the PyCF_ALLOW_TOP_LEVEL_AWAIT flag
and make sure the generated code object has the CO_COROUTINE flag set in
set, and make sure the generated code object has the CO_COROUTINE flag
order to execute it with `await eval(.....)` instead of exec, or via a
set in order to execute it with `await eval(.....)` instead of exec,
FunctionType.
or via a
FunctionType.
"""
"""
# helper function just to check we can run top=level async-for
# helper function just to check we can run top=level async-for
...
@@ -379,17 +379,20 @@ class BuiltinTest(unittest.TestCase):
...
@@ -379,17 +379,20 @@ class BuiltinTest(unittest.TestCase):
yield
i
yield
i
modes
=
(
'single'
,
'exec'
)
modes
=
(
'single'
,
'exec'
)
code_samples
=
[
'''a = await asyncio.sleep(0, result=1)'''
,
code_samples
=
[
'''async for i in arange(1):
'''a = await asyncio.sleep(0, result=1)'''
,
a = 1'''
,
'''async for i in arange(1):
'''async with asyncio.Lock() as l:
a = 1'''
,
a = 1'''
]
'''async with asyncio.Lock() as l:
a = 1'''
]
policy
=
maybe_get_event_loop_policy
()
policy
=
maybe_get_event_loop_policy
()
try
:
try
:
for
mode
,
code_sample
in
product
(
modes
,
code_samples
):
for
mode
,
code_sample
in
product
(
modes
,
code_samples
):
source
=
dedent
(
code_sample
)
source
=
dedent
(
code_sample
)
with
self
.
assertRaises
(
SyntaxError
,
msg
=
f
"{source=} {mode=}"
):
with
self
.
assertRaises
(
compile
(
source
,
'?'
,
mode
)
SyntaxError
,
msg
=
f
"source={source} mode={mode}"
):
compile
(
source
,
'?'
,
mode
)
co
=
compile
(
source
,
co
=
compile
(
source
,
'?'
,
'?'
,
...
@@ -397,17 +400,16 @@ class BuiltinTest(unittest.TestCase):
...
@@ -397,17 +400,16 @@ class BuiltinTest(unittest.TestCase):
flags
=
ast
.
PyCF_ALLOW_TOP_LEVEL_AWAIT
)
flags
=
ast
.
PyCF_ALLOW_TOP_LEVEL_AWAIT
)
self
.
assertEqual
(
co
.
co_flags
&
CO_COROUTINE
,
CO_COROUTINE
,
self
.
assertEqual
(
co
.
co_flags
&
CO_COROUTINE
,
CO_COROUTINE
,
msg
=
f
"{source=} {mode=}"
)
msg
=
f
"source={source} mode={mode}"
)
# test we can create and advance a function type
# test we can create and advance a function type
globals_
=
{
'asyncio'
:
asyncio
,
'a'
:
0
,
'arange'
:
arange
}
globals_
=
{
'asyncio'
:
asyncio
,
'a'
:
0
,
'arange'
:
arange
}
async_f
=
FunctionType
(
co
,
globals_
)
async_f
=
FunctionType
(
co
,
globals_
)
asyncio
.
run
(
async_f
())
asyncio
.
run
(
async_f
())
self
.
assertEqual
(
globals_
[
'a'
],
1
)
self
.
assertEqual
(
globals_
[
'a'
],
1
)
# test we can await-eval,
# test we can await-eval,
globals_
=
{
'asyncio'
:
asyncio
,
'a'
:
0
,
'arange'
:
arange
}
globals_
=
{
'asyncio'
:
asyncio
,
'a'
:
0
,
'arange'
:
arange
}
asyncio
.
run
(
eval
(
co
,
globals_
))
asyncio
.
run
(
eval
(
co
,
globals_
))
self
.
assertEqual
(
globals_
[
'a'
],
1
)
self
.
assertEqual
(
globals_
[
'a'
],
1
)
finally
:
finally
:
...
@@ -416,7 +418,8 @@ class BuiltinTest(unittest.TestCase):
...
@@ -416,7 +418,8 @@ class BuiltinTest(unittest.TestCase):
def
test_compile_async_generator
(
self
):
def
test_compile_async_generator
(
self
):
"""
"""
With the PyCF_ALLOW_TOP_LEVEL_AWAIT flag added in 3.8, we want to
With the PyCF_ALLOW_TOP_LEVEL_AWAIT flag added in 3.8, we want to
make sure AsyncGenerators are still properly not marked with CO_COROUTINE
make sure AsyncGenerators are still properly not marked with the
CO_COROUTINE flag.
"""
"""
code
=
dedent
(
"""async def ticker():
code
=
dedent
(
"""async def ticker():
for i in range(10):
for i in range(10):
...
@@ -428,7 +431,6 @@ class BuiltinTest(unittest.TestCase):
...
@@ -428,7 +431,6 @@ class BuiltinTest(unittest.TestCase):
exec
(
co
,
glob
)
exec
(
co
,
glob
)
self
.
assertEqual
(
type
(
glob
[
'ticker'
]()),
AsyncGeneratorType
)
self
.
assertEqual
(
type
(
glob
[
'ticker'
]()),
AsyncGeneratorType
)
def
test_delattr
(
self
):
def
test_delattr
(
self
):
sys
.
spam
=
1
sys
.
spam
=
1
delattr
(
sys
,
'spam'
)
delattr
(
sys
,
'spam'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment