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
Boxiang Sun
cython
Commits
a5f77c7f
Commit
a5f77c7f
authored
Apr 10, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adapted doctests to PyPy
parent
59782372
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
54 additions
and
76 deletions
+54
-76
tests/run/callargs.pyx
tests/run/callargs.pyx
+8
-8
tests/run/consts.pyx
tests/run/consts.pyx
+16
-24
tests/run/duplicate_keyword_in_call.py
tests/run/duplicate_keyword_in_call.py
+3
-4
tests/run/exttype.pyx
tests/run/exttype.pyx
+2
-2
tests/run/import_error_T734.py
tests/run/import_error_T734.py
+2
-2
tests/run/kwargproblems.pyx
tests/run/kwargproblems.pyx
+3
-3
tests/run/pure.pyx
tests/run/pure.pyx
+2
-4
tests/run/struct_conversion.pyx
tests/run/struct_conversion.pyx
+4
-8
tests/run/unpack.pyx
tests/run/unpack.pyx
+14
-21
No files found.
tests/run/callargs.pyx
View file @
a5f77c7f
...
@@ -166,17 +166,17 @@ def test_noargs(f):
...
@@ -166,17 +166,17 @@ def test_noargs(f):
def
test_int_kwargs
(
f
):
def
test_int_kwargs
(
f
):
"""
"""
>>> test_int_kwargs(e)
>>> test_int_kwargs(e)
# doctest: +ELLIPSIS
Traceback (most recent call last):
Traceback (most recent call last):
TypeError:
e()
keywords must be strings
TypeError:
...
keywords must be strings
>>> test_int_kwargs(f)
>>> test_int_kwargs(f)
# doctest: +ELLIPSIS
Traceback (most recent call last):
Traceback (most recent call last):
TypeError:
f()
keywords must be strings
TypeError:
...
keywords must be strings
>>> test_int_kwargs(g)
>>> test_int_kwargs(g)
# doctest: +ELLIPSIS
Traceback (most recent call last):
Traceback (most recent call last):
TypeError:
g()
keywords must be strings
TypeError:
...
keywords must be strings
>>> test_int_kwargs(h)
>>> test_int_kwargs(h)
# doctest: +ELLIPSIS
Traceback (most recent call last):
Traceback (most recent call last):
TypeError:
h()
keywords must be strings
TypeError:
...
keywords must be strings
"""
"""
f
(
a
=
1
,
b
=
2
,
c
=
3
,
**
{
10
:
20
,
30
:
40
})
f
(
a
=
1
,
b
=
2
,
c
=
3
,
**
{
10
:
20
,
30
:
40
})
tests/run/consts.pyx
View file @
a5f77c7f
...
@@ -133,18 +133,14 @@ def multiplied_lists_nonconst(x):
...
@@ -133,18 +133,14 @@ def multiplied_lists_nonconst(x):
>>> multiplied_lists_nonconst(0) == [1,2,3] * 0
>>> multiplied_lists_nonconst(0) == [1,2,3] * 0
True
True
>>> [1,2,3] * 'abc' # doctest: +ELLIPSIS
>>> try: [1,2,3] * 'abc'
Traceback (most recent call last):
... except TypeError: pass
TypeError: can't multiply sequence by non-int...
>>> try: multiplied_nonconst_tuple_arg('abc')
>>> multiplied_nonconst_tuple_arg('abc') # doctest: +ELLIPSIS
... except TypeError: pass
Traceback (most recent call last):
>>> try: [1,2,3] * 1.0
TypeError: can't multiply sequence by non-int...
... except TypeError: pass
>>> [1,2,3] * 1.0 # doctest: +ELLIPSIS
>>> try: multiplied_nonconst_tuple_arg(1.0)
Traceback (most recent call last):
... except TypeError: pass
TypeError: can't multiply sequence by non-int...
>>> multiplied_nonconst_tuple_arg(1.0) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: can't multiply sequence by non-int...
"""
"""
return
[
1
,
2
,
3
]
*
x
return
[
1
,
2
,
3
]
*
x
...
@@ -209,18 +205,14 @@ def multiplied_nonconst_tuple_arg(x):
...
@@ -209,18 +205,14 @@ def multiplied_nonconst_tuple_arg(x):
>>> multiplied_nonconst_tuple_arg(0) == (1,2) * 0
>>> multiplied_nonconst_tuple_arg(0) == (1,2) * 0
True
True
>>> (1,2) * 'abc' # doctest: +ELLIPSIS
>>> try: (1,2) * 'abc'
Traceback (most recent call last):
... except TypeError: pass
TypeError: can't multiply sequence by non-int...
>>> try: multiplied_nonconst_tuple_arg('abc')
>>> multiplied_nonconst_tuple_arg('abc') # doctest: +ELLIPSIS
... except TypeError: pass
Traceback (most recent call last):
>>> try: (1,2) * 1.0
TypeError: can't multiply sequence by non-int...
... except TypeError: pass
>>> (1,2) * 1.0 # doctest: +ELLIPSIS
>>> try: multiplied_nonconst_tuple_arg(1.0)
Traceback (most recent call last):
... except TypeError: pass
TypeError: can't multiply sequence by non-int...
>>> multiplied_nonconst_tuple_arg(1.0) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: can't multiply sequence by non-int...
"""
"""
return
(
1
,
2
)
*
x
return
(
1
,
2
)
*
x
...
...
tests/run/duplicate_keyword_in_call.py
View file @
a5f77c7f
...
@@ -14,13 +14,12 @@ def test_call(kwargs):
...
@@ -14,13 +14,12 @@ def test_call(kwargs):
[('a', 1), ('b', 2)]
[('a', 1), ('b', 2)]
>>> kwargs = {'a' : 2}
>>> kwargs = {'a' : 2}
>>> f(a=1, **kwargs)
>>> f(a=1, **kwargs)
# doctest: +ELLIPSIS
Traceback (most recent call last):
Traceback (most recent call last):
TypeError:
f()
got multiple values for keyword argument 'a'
TypeError:
...
got multiple values for keyword argument 'a'
FIXME: remove ellipsis, fix function name
>>> test_call(kwargs) # doctest: +ELLIPSIS
>>> test_call(kwargs) # doctest: +ELLIPSIS
Traceback (most recent call last):
Traceback (most recent call last):
TypeError: ...
()
got multiple values for keyword argument 'a'
TypeError: ...got multiple values for keyword argument 'a'
"""
"""
return
f
(
a
=
1
,
**
kwargs
)
return
f
(
a
=
1
,
**
kwargs
)
tests/run/exttype.pyx
View file @
a5f77c7f
...
@@ -24,9 +24,9 @@ cdef class Spam:
...
@@ -24,9 +24,9 @@ cdef class Spam:
def
f
(
Spam
spam
):
def
f
(
Spam
spam
):
"""
"""
>>> s = Spam(12)
>>> s = Spam(12)
>>> f(s)
>>> f(s)
# doctest: +ELLIPSIS
Traceback (most recent call last):
Traceback (most recent call last):
AttributeError: '
exttype
.Spam' object has no attribute 'foo'
AttributeError: '
..
.Spam' object has no attribute 'foo'
>>> s.eat()
>>> s.eat()
12 42
12 42
>>> class Spam2(Spam):
>>> class Spam2(Spam):
...
...
tests/run/import_error_T734.py
View file @
a5f77c7f
...
@@ -3,8 +3,8 @@
...
@@ -3,8 +3,8 @@
def
test_import_error
():
def
test_import_error
():
"""
"""
>>> test_import_error()
>>> test_import_error()
# doctest: +ELLIPSIS
Traceback (most recent call last):
Traceback (most recent call last):
ImportError: cannot import name
xxx
ImportError: cannot import name
...xxx...
"""
"""
from
sys
import
xxx
from
sys
import
xxx
tests/run/kwargproblems.pyx
View file @
a5f77c7f
...
@@ -2,9 +2,9 @@
...
@@ -2,9 +2,9 @@
def
test
(
**
kw
):
def
test
(
**
kw
):
"""
"""
>>> d = {1 : 2}
>>> d = {1 : 2}
>>> test(**d)
>>> test(**d)
# doctest: +ELLIPSIS
Traceback (most recent call last):
Traceback (most recent call last):
TypeError:
test()
keywords must be strings
TypeError:
...
keywords must be strings
>>> d
>>> d
{1: 2}
{1: 2}
>>> d = {}
>>> d = {}
...
@@ -12,7 +12,7 @@ def test(**kw):
...
@@ -12,7 +12,7 @@ def test(**kw):
{'arg': 3}
{'arg': 3}
>>> d
>>> d
{}
{}
>>> d = {'arg' : 2}
# this should be u'arg', but Py2 can't handle it...
>>> d = {'arg' : 2}
>>> test(**d)
>>> test(**d)
{'arg': 3}
{'arg': 3}
>>> d
>>> d
...
...
tests/run/pure.pyx
View file @
a5f77c7f
...
@@ -43,10 +43,8 @@ def test_cast(x):
...
@@ -43,10 +43,8 @@ def test_cast(x):
"""
"""
>>> test_cast(1.5)
>>> test_cast(1.5)
1
1
>>> test_cast(None)
>>> try: test_cast(None)
Traceback (most recent call last):
... except TypeError: pass
...
TypeError: a float is required
"""
"""
n
=
cython
.
cast
(
cython
.
int
,
x
)
n
=
cython
.
cast
(
cython
.
int
,
x
)
return
n
return
n
...
...
tests/run/struct_conversion.pyx
View file @
a5f77c7f
...
@@ -7,10 +7,8 @@ def test_constructor(x, y, color):
...
@@ -7,10 +7,8 @@ def test_constructor(x, y, color):
"""
"""
>>> sorted(test_constructor(1,2,255).items())
>>> sorted(test_constructor(1,2,255).items())
[('color', 255), ('x', 1.0), ('y', 2.0)]
[('color', 255), ('x', 1.0), ('y', 2.0)]
>>> test_constructor(1,None,255)
>>> try: test_constructor(1,None,255)
Traceback (most recent call last):
... except TypeError: pass
...
TypeError: a float is required
"""
"""
cdef
Point
p
=
Point
(
x
,
y
,
color
)
cdef
Point
p
=
Point
(
x
,
y
,
color
)
return
p
return
p
...
@@ -31,10 +29,8 @@ def test_dict_construction(x, y, color):
...
@@ -31,10 +29,8 @@ def test_dict_construction(x, y, color):
"""
"""
>>> sorted(test_dict_construction(4, 5, 64).items())
>>> sorted(test_dict_construction(4, 5, 64).items())
[('color', 64), ('x', 4.0), ('y', 5.0)]
[('color', 64), ('x', 4.0), ('y', 5.0)]
>>> test_dict_construction("foo", 5, 64)
>>> try: test_dict_construction("foo", 5, 64)
Traceback (most recent call last):
... except TypeError: pass
...
TypeError: a float is required
"""
"""
cdef
Point
p
=
{
'color'
:
color
,
'x'
:
x
,
'y'
:
y
}
cdef
Point
p
=
{
'color'
:
color
,
'x'
:
x
,
'y'
:
y
}
return
p
return
p
...
...
tests/run/unpack.pyx
View file @
a5f77c7f
...
@@ -180,16 +180,13 @@ def unpack_typed(it):
...
@@ -180,16 +180,13 @@ def unpack_typed(it):
>>> it.count
>>> it.count
4
4
>>> unpack_typed((1, None, [1]))
>>> try: unpack_typed((1, None, [1]))
Traceback (most recent call last):
... except TypeError: pass
TypeError: a float is required
>>> try: unpack_typed([1, None, [1]])
>>> unpack_typed([1, None, [1]])
... except TypeError: pass
Traceback (most recent call last):
TypeError: a float is required
>>> it = ItCount([1, None, [1]])
>>> it = ItCount([1, None, [1]])
>>> unpack_typed(it)
>>> try: unpack_typed(it)
Traceback (most recent call last):
... except TypeError: pass
TypeError: a float is required
>>> it.count
>>> it.count
4
4
...
@@ -211,16 +208,14 @@ def unpack_typed(it):
...
@@ -211,16 +208,14 @@ def unpack_typed(it):
def
failure_too_many
(
it
):
def
failure_too_many
(
it
):
"""
"""
>>> a,b,c = [1,2,3,4] # doctest: +ELLIPSIS
>>> try: a,b,c = [1,2,3,4]
Traceback (most recent call last):
... except ValueError: pass
ValueError: too many values to unpack...
>>> failure_too_many([1,2,3,4])
>>> failure_too_many([1,2,3,4])
Traceback (most recent call last):
Traceback (most recent call last):
ValueError: too many values to unpack (expected 3)
ValueError: too many values to unpack (expected 3)
>>> a,b,c = [1,2,3,4] # doctest: +ELLIPSIS
>>> try: a,b,c = [1,2,3,4]
Traceback (most recent call last):
... except ValueError: pass
ValueError: too many values to unpack...
>>> failure_too_many((1,2,3,4))
>>> failure_too_many((1,2,3,4))
Traceback (most recent call last):
Traceback (most recent call last):
ValueError: too many values to unpack (expected 3)
ValueError: too many values to unpack (expected 3)
...
@@ -244,16 +239,14 @@ def failure_too_many(it):
...
@@ -244,16 +239,14 @@ def failure_too_many(it):
def
failure_too_few
(
it
):
def
failure_too_few
(
it
):
"""
"""
>>> a,b,c = [1,2]
>>> try: a,b,c = [1,2]
Traceback (most recent call last):
... except ValueError: pass
ValueError: need more than 2 values to unpack
>>> failure_too_few([1,2])
>>> failure_too_few([1,2])
Traceback (most recent call last):
Traceback (most recent call last):
ValueError: need more than 2 values to unpack
ValueError: need more than 2 values to unpack
>>> a,b,c = (1,2)
>>> try: a,b,c = (1,2)
Traceback (most recent call last):
... except ValueError: pass
ValueError: need more than 2 values to unpack
>>> failure_too_few((1,2))
>>> failure_too_few((1,2))
Traceback (most recent call last):
Traceback (most recent call last):
ValueError: need more than 2 values to unpack
ValueError: need more than 2 values to unpack
...
...
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