Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
e6078dfe
Commit
e6078dfe
authored
Sep 28, 2018
by
Damien George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests/basics: Split out gen throw tests from yield-from-throw tests.
parent
e9012a20
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
27 deletions
+44
-27
tests/basics/gen_yield_from_throw.py
tests/basics/gen_yield_from_throw.py
+0
-26
tests/basics/generator_throw.py
tests/basics/generator_throw.py
+43
-0
tests/run-tests
tests/run-tests
+1
-1
No files found.
tests/basics/gen_yield_from_throw.py
View file @
e6078dfe
...
...
@@ -16,29 +16,3 @@ try:
print
(
next
(
g
))
except
TypeError
:
print
(
"got TypeError from downstream!"
)
# case where generator doesn't intercept the thrown/injected exception
def
gen3
():
yield
123
yield
456
g3
=
gen3
()
print
(
next
(
g3
))
try
:
g3
.
throw
(
KeyError
)
except
KeyError
:
print
(
'got KeyError from downstream!'
)
# case where a thrown exception is caught and stops the generator
def
gen4
():
try
:
yield
1
yield
2
except
:
pass
g4
=
gen4
()
print
(
next
(
g4
))
try
:
g4
.
throw
(
ValueError
)
except
StopIteration
:
print
(
'got StopIteration'
)
tests/basics/generator_throw.py
0 → 100644
View file @
e6078dfe
# case where generator doesn't intercept the thrown/injected exception
def
gen
():
yield
123
yield
456
g
=
gen
()
print
(
next
(
g
))
try
:
g
.
throw
(
KeyError
)
except
KeyError
:
print
(
'got KeyError from downstream!'
)
# case where a thrown exception is caught and stops the generator
def
gen
():
try
:
yield
1
yield
2
except
:
pass
g
=
gen
()
print
(
next
(
g
))
try
:
g
.
throw
(
ValueError
)
except
StopIteration
:
print
(
'got StopIteration'
)
# generator ignores a thrown GeneratorExit (this is allowed)
def
gen
():
try
:
yield
123
except
GeneratorExit
:
print
(
'GeneratorExit'
)
yield
456
# thrown a class
g
=
gen
()
print
(
next
(
g
))
print
(
g
.
throw
(
GeneratorExit
))
# thrown an instance
g
=
gen
()
print
(
next
(
g
))
print
(
g
.
throw
(
GeneratorExit
()))
tests/run-tests
View file @
e6078dfe
...
...
@@ -352,7 +352,7 @@ def run_tests(pyb, tests, args, base_path="."):
# Some tests are known to fail with native emitter
# Remove them from the below when they work
if
args
.
emit
==
'native'
:
skip_tests
.
update
({
'basics/%s.py'
%
t
for
t
in
'gen_yield_from gen_yield_from_close gen_yield_from_ducktype gen_yield_from_exc gen_yield_from_executing gen_yield_from_iter gen_yield_from_send gen_yield_from_stopped gen_yield_from_throw gen_yield_from_throw2 gen_yield_from_throw3 generator1 generator2 generator_args generator_close generator_closure generator_exc generator_name generator_pend_throw generator_return generator_send generator_pep479'
.
split
()})
# require yield
skip_tests
.
update
({
'basics/%s.py'
%
t
for
t
in
'gen_yield_from gen_yield_from_close gen_yield_from_ducktype gen_yield_from_exc gen_yield_from_executing gen_yield_from_iter gen_yield_from_send gen_yield_from_stopped gen_yield_from_throw gen_yield_from_throw2 gen_yield_from_throw3 generator1 generator2 generator_args generator_close generator_closure generator_exc generator_name generator_pend_throw generator_return generator_send generator_
throw generator_
pep479'
.
split
()})
# require yield
skip_tests
.
update
({
'basics/%s.py'
%
t
for
t
in
'bytes_gen class_store_class globals_del string_join'
.
split
()})
# require yield
skip_tests
.
update
({
'basics/async_%s.py'
%
t
for
t
in
'def await await2 for for2 with with2 with_break with_return'
.
split
()})
# require yield
skip_tests
.
update
({
'basics/%s.py'
%
t
for
t
in
'try_reraise try_reraise2'
.
split
()})
# require raise_varargs
...
...
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