Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
b495377a
Commit
b495377a
authored
Jan 02, 2018
by
Serhiy Storchaka
Committed by
GitHub
Jan 02, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.7] bpo-32478: Add tests for 'break' and 'return' inside 'finally' clause. (GH-5078). (#5084)
(cherry picked from commit
7cc42c35
)
parent
2de47ca1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
0 deletions
+74
-0
Lib/test/test_grammar.py
Lib/test/test_grammar.py
+74
-0
No files found.
Lib/test/test_grammar.py
View file @
b495377a
...
@@ -490,6 +490,80 @@ hello world
...
@@ -490,6 +490,80 @@ hello world
x
=
g2
()
x
=
g2
()
check_syntax_error
(
self
,
"class foo:return 1"
)
check_syntax_error
(
self
,
"class foo:return 1"
)
def
test_break_in_finally
(
self
):
count
=
0
while
count
<
2
:
count
+=
1
try
:
pass
finally
:
break
self
.
assertEqual
(
count
,
1
)
count
=
0
while
count
<
2
:
count
+=
1
try
:
continue
finally
:
break
self
.
assertEqual
(
count
,
1
)
count
=
0
while
count
<
2
:
count
+=
1
try
:
1
/
0
finally
:
break
self
.
assertEqual
(
count
,
1
)
for
count
in
[
0
,
1
]:
self
.
assertEqual
(
count
,
0
)
try
:
pass
finally
:
break
self
.
assertEqual
(
count
,
0
)
for
count
in
[
0
,
1
]:
self
.
assertEqual
(
count
,
0
)
try
:
continue
finally
:
break
self
.
assertEqual
(
count
,
0
)
for
count
in
[
0
,
1
]:
self
.
assertEqual
(
count
,
0
)
try
:
1
/
0
finally
:
break
self
.
assertEqual
(
count
,
0
)
def
test_return_in_finally
(
self
):
def
g1
():
try
:
pass
finally
:
return
1
self
.
assertEqual
(
g1
(),
1
)
def
g2
():
try
:
return
2
finally
:
return
3
self
.
assertEqual
(
g2
(),
3
)
def
g3
():
try
:
1
/
0
finally
:
return
4
self
.
assertEqual
(
g3
(),
4
)
def
testYield
(
self
):
def
testYield
(
self
):
check_syntax_error
(
self
,
"class foo:yield 1"
)
check_syntax_error
(
self
,
"class foo:yield 1"
)
...
...
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