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
fc35de40
Kaydet (Commit)
fc35de40
authored
Mar 02, 2001
tarafından
Tim Peters
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
test_global was broken by some recent checkin. Repairing.
üst
7a25765f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
9 deletions
+15
-9
test_global
Lib/test/output/test_global
+1
-1
test_global.py
Lib/test/test_global.py
+14
-8
No files found.
Lib/test/output/test_global
Dosyayı görüntüle @
fc35de40
...
...
@@ -2,4 +2,4 @@ test_global
got SyntaxError as expected
got SyntaxError as expected
got SyntaxError as expected
got SyntaxError as expected
as expected, no SyntaxError
Lib/test/test_global.py
Dosyayı görüntüle @
fc35de40
"""Verify that warnings are issued for global statements following use"""
"""Verify that warnings are issued for global statements following use
.
"""
from
test_support
import
check_syntax
...
...
@@ -6,13 +6,19 @@ import warnings
warnings
.
filterwarnings
(
"error"
,
module
=
"<test code>"
)
def
compile_and_c
atch_warning
(
text
):
def
compile_and_c
heck
(
text
,
should_fail
=
1
):
try
:
compile
(
text
,
"<test code>"
,
"exec"
)
except
SyntaxError
,
msg
:
print
"got SyntaxError as expected"
if
should_fail
:
print
"got SyntaxError as expected"
else
:
print
"raised unexpected SyntaxError:"
,
text
else
:
print
"expected SyntaxError"
if
should_fail
:
print
"should have raised SyntaxError:"
,
text
else
:
print
"as expected, no SyntaxError"
prog_text_1
=
"""
def wrong1():
...
...
@@ -21,14 +27,14 @@ def wrong1():
global a
global b
"""
compile_and_c
atch_warning
(
prog_text_1
)
compile_and_c
heck
(
prog_text_1
)
prog_text_2
=
"""
def wrong2():
print x
global x
"""
compile_and_c
atch_warning
(
prog_text_2
)
compile_and_c
heck
(
prog_text_2
)
prog_text_3
=
"""
def wrong3():
...
...
@@ -36,10 +42,10 @@ def wrong3():
x = 2
global x
"""
compile_and_c
atch_warning
(
prog_text_3
)
compile_and_c
heck
(
prog_text_3
)
prog_text_4
=
"""
global x
x = 2
"""
compile_and_c
atch_warning
(
prog_text_4
)
compile_and_c
heck
(
prog_text_4
,
0
)
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