Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
5abdcce5
Commit
5abdcce5
authored
Feb 09, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up exec test file
parent
7dc8c56e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
60 deletions
+66
-60
tests/run/exectest.pyx
tests/run/exectest.pyx
+66
-60
No files found.
tests/run/exectest.pyx
View file @
5abdcce5
...
...
@@ -6,66 +6,6 @@ __doc__ = u"""
#NameError: name 'a' is not defined
#>>> test_module_scope()
#>>> a
>>> test_dict_scope1()
2
>>> d = {}
>>> test_dict_scope2(d)
>>> d['b']
2
>>> d1 = {}
>>> test_dict_scope3(d1, d1)
>>> d1['b']
2
>>> d1, d2 = {}, {}
>>> test_dict_scope3(d1, d2)
>>> (d1.get('b'), d2.get('b'))
(None, 2)
>>> d1, d2 = {}, {}
>>> test_dict_scope3(d1, d2)
>>> (d1.get('b'), d2.get('b'))
(None, 2)
>>> d1, d2 = dict(a=11), dict(c=5)
>>> test_dict_scope_ref(d1, d2)
>>> (d1.get('b'), d2.get('b'))
(None, 16)
>>> d = dict(a=11, c=5)
>>> test_dict_scope_ref(d, d)
>>> d['b']
16
>>> d = dict(seq = [1,2,3,4])
>>> add_iter = test_def(d, 'seq')
>>> list(add_iter())
[2, 3, 4, 5]
>>> d = {}
>>> test_encoding(d, None)
>>> print(d['b'])
üöä
>>> d = {}
>>> test_encoding_unicode(d, None)
>>> print(d['b'])
üöä
>>> d = dict(a=1, c=3)
>>> test_compile(d)
>>> d['b']
4
>>> # errors
>>> d1, d2 = {}, {}
>>> test_dict_scope_ref(d1, d2) # doctest: +ELLIPSIS
Traceback (most recent call last):
NameError: ...name 'a' is not defined
"""
#def test_module_scope():
...
...
@@ -73,17 +13,59 @@ NameError: ...name 'a' is not defined
# return __dict__['a']
def
test_dict_scope1
():
"""
>>> test_dict_scope1()
2
"""
cdef
dict
d
=
{}
exec
u"b=1+1"
in
d
return
d
[
u'b'
]
def
test_dict_scope2
(
d
):
"""
>>> d = {}
>>> test_dict_scope2(d)
>>> d['b']
2
"""
exec
u"b=1+1"
in
d
def
test_dict_scope3
(
d1
,
d2
):
"""
>>> d1 = {}
>>> test_dict_scope3(d1, d1)
>>> d1['b']
2
>>> d1, d2 = {}, {}
>>> test_dict_scope3(d1, d2)
>>> (d1.get('b'), d2.get('b'))
(None, 2)
>>> d1, d2 = {}, {}
>>> test_dict_scope3(d1, d2)
>>> (d1.get('b'), d2.get('b'))
(None, 2)
"""
exec
u"b=1+1"
in
d1
,
d2
def
test_dict_scope_ref
(
d1
,
d2
):
"""
>>> d1, d2 = dict(a=11), dict(c=5)
>>> test_dict_scope_ref(d1, d2)
>>> (d1.get('b'), d2.get('b'))
(None, 16)
>>> d = dict(a=11, c=5)
>>> test_dict_scope_ref(d, d)
>>> d['b']
16
>>> d1, d2 = {}, {}
>>> test_dict_scope_ref(d1, d2) # doctest: +ELLIPSIS
Traceback (most recent call last):
NameError: ...name 'a' is not defined
"""
exec
u"b=a+c"
in
d1
,
d2
def
test_dict_scope_tuple2
():
...
...
@@ -105,6 +87,12 @@ def test_dict_scope_tuple3(d1, d2):
exec
(
u"b=1+1"
,
d1
,
d2
)
def
test_def
(
d
,
varref
):
"""
>>> d = dict(seq = [1,2,3,4])
>>> add_iter = test_def(d, 'seq')
>>> list(add_iter())
[2, 3, 4, 5]
"""
exec
u"""
def test():
for x in %s:
...
...
@@ -115,6 +103,12 @@ def test():
import
sys
def
test_encoding
(
d1
,
d2
):
u"""
>>> d = {}
>>> test_encoding(d, None)
>>> print(d['b'])
üöä
"""
if
sys
.
version_info
[
0
]
>=
3
:
s
=
"b = 'üöä'"
else
:
...
...
@@ -122,6 +116,12 @@ def test_encoding(d1, d2):
exec
s
in
d1
,
d2
def
test_encoding_unicode
(
d1
,
d2
):
u"""
>>> d = {}
>>> test_encoding_unicode(d, None)
>>> print(d['b'])
üöä
"""
if
sys
.
version_info
[
0
]
>=
3
:
s
=
u"b = 'üöä'"
else
:
...
...
@@ -129,6 +129,12 @@ def test_encoding_unicode(d1, d2):
exec
s
in
d1
,
d2
def
test_compile
(
d
):
"""
>>> d = dict(a=1, c=3)
>>> test_compile(d)
>>> d['b']
4
"""
c
=
compile
(
u"b = a+c"
,
u"<string>"
,
u"exec"
)
exec
c
in
d
...
...
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