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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
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):
def
test_int_kwargs
(
f
):
"""
>>> test_int_kwargs(e)
>>> test_int_kwargs(e)
# doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError:
e()
keywords must be strings
>>> test_int_kwargs(f)
TypeError:
...
keywords must be strings
>>> test_int_kwargs(f)
# doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError:
f()
keywords must be strings
>>> test_int_kwargs(g)
TypeError:
...
keywords must be strings
>>> test_int_kwargs(g)
# doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError:
g()
keywords must be strings
>>> test_int_kwargs(h)
TypeError:
...
keywords must be strings
>>> test_int_kwargs(h)
# doctest: +ELLIPSIS
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
})
tests/run/consts.pyx
View file @
a5f77c7f
...
...
@@ -133,18 +133,14 @@ def multiplied_lists_nonconst(x):
>>> multiplied_lists_nonconst(0) == [1,2,3] * 0
True
>>> [1,2,3] * 'abc' # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: can't multiply sequence by non-int...
>>> multiplied_nonconst_tuple_arg('abc') # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: can't multiply sequence by non-int...
>>> [1,2,3] * 1.0 # doctest: +ELLIPSIS
Traceback (most recent call last):
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...
>>> try: [1,2,3] * 'abc'
... except TypeError: pass
>>> try: multiplied_nonconst_tuple_arg('abc')
... except TypeError: pass
>>> try: [1,2,3] * 1.0
... except TypeError: pass
>>> try: multiplied_nonconst_tuple_arg(1.0)
... except TypeError: pass
"""
return
[
1
,
2
,
3
]
*
x
...
...
@@ -209,18 +205,14 @@ def multiplied_nonconst_tuple_arg(x):
>>> multiplied_nonconst_tuple_arg(0) == (1,2) * 0
True
>>> (1,2) * 'abc' # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: can't multiply sequence by non-int...
>>> multiplied_nonconst_tuple_arg('abc') # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: can't multiply sequence by non-int...
>>> (1,2) * 1.0 # doctest: +ELLIPSIS
Traceback (most recent call last):
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...
>>> try: (1,2) * 'abc'
... except TypeError: pass
>>> try: multiplied_nonconst_tuple_arg('abc')
... except TypeError: pass
>>> try: (1,2) * 1.0
... except TypeError: pass
>>> try: multiplied_nonconst_tuple_arg(1.0)
... except TypeError: pass
"""
return
(
1
,
2
)
*
x
...
...
tests/run/duplicate_keyword_in_call.py
View file @
a5f77c7f
...
...
@@ -14,13 +14,12 @@ def test_call(kwargs):
[('a', 1), ('b', 2)]
>>> kwargs = {'a' : 2}
>>> f(a=1, **kwargs)
>>> f(a=1, **kwargs)
# doctest: +ELLIPSIS
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
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
)
tests/run/exttype.pyx
View file @
a5f77c7f
...
...
@@ -24,9 +24,9 @@ cdef class Spam:
def
f
(
Spam
spam
):
"""
>>> s = Spam(12)
>>> f(s)
>>> f(s)
# doctest: +ELLIPSIS
Traceback (most recent call last):
AttributeError: '
exttype
.Spam' object has no attribute 'foo'
AttributeError: '
..
.Spam' object has no attribute 'foo'
>>> s.eat()
12 42
>>> class Spam2(Spam):
...
...
tests/run/import_error_T734.py
View file @
a5f77c7f
...
...
@@ -3,8 +3,8 @@
def
test_import_error
():
"""
>>> test_import_error()
>>> test_import_error()
# doctest: +ELLIPSIS
Traceback (most recent call last):
ImportError: cannot import name
xxx
ImportError: cannot import name
...xxx...
"""
from
sys
import
xxx
tests/run/kwargproblems.pyx
View file @
a5f77c7f
...
...
@@ -2,9 +2,9 @@
def
test
(
**
kw
):
"""
>>> d = {1 : 2}
>>> test(**d)
>>> test(**d)
# doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError:
test()
keywords must be strings
TypeError:
...
keywords must be strings
>>> d
{1: 2}
>>> d = {}
...
...
@@ -12,7 +12,7 @@ def test(**kw):
{'arg': 3}
>>> d
{}
>>> d = {'arg' : 2}
# this should be u'arg', but Py2 can't handle it...
>>> d = {'arg' : 2}
>>> test(**d)
{'arg': 3}
>>> d
...
...
tests/run/pure.pyx
View file @
a5f77c7f
...
...
@@ -43,10 +43,8 @@ def test_cast(x):
"""
>>> test_cast(1.5)
1
>>> test_cast(None)
Traceback (most recent call last):
...
TypeError: a float is required
>>> try: test_cast(None)
... except TypeError: pass
"""
n
=
cython
.
cast
(
cython
.
int
,
x
)
return
n
...
...
tests/run/struct_conversion.pyx
View file @
a5f77c7f
...
...
@@ -7,10 +7,8 @@ def test_constructor(x, y, color):
"""
>>> sorted(test_constructor(1,2,255).items())
[('color', 255), ('x', 1.0), ('y', 2.0)]
>>> test_constructor(1,None,255)
Traceback (most recent call last):
...
TypeError: a float is required
>>> try: test_constructor(1,None,255)
... except TypeError: pass
"""
cdef
Point
p
=
Point
(
x
,
y
,
color
)
return
p
...
...
@@ -31,10 +29,8 @@ def test_dict_construction(x, y, color):
"""
>>> sorted(test_dict_construction(4, 5, 64).items())
[('color', 64), ('x', 4.0), ('y', 5.0)]
>>> test_dict_construction("foo", 5, 64)
Traceback (most recent call last):
...
TypeError: a float is required
>>> try: test_dict_construction("foo", 5, 64)
... except TypeError: pass
"""
cdef
Point
p
=
{
'color'
:
color
,
'x'
:
x
,
'y'
:
y
}
return
p
...
...
tests/run/unpack.pyx
View file @
a5f77c7f
...
...
@@ -180,16 +180,13 @@ def unpack_typed(it):
>>> it.count
4
>>> unpack_typed((1, None, [1]))
Traceback (most recent call last):
TypeError: a float is required
>>> unpack_typed([1, None, [1]])
Traceback (most recent call last):
TypeError: a float is required
>>> try: unpack_typed((1, None, [1]))
... except TypeError: pass
>>> try: unpack_typed([1, None, [1]])
... except TypeError: pass
>>> it = ItCount([1, None, [1]])
>>> unpack_typed(it)
Traceback (most recent call last):
TypeError: a float is required
>>> try: unpack_typed(it)
... except TypeError: pass
>>> it.count
4
...
...
@@ -211,16 +208,14 @@ def unpack_typed(it):
def
failure_too_many
(
it
):
"""
>>> a,b,c = [1,2,3,4] # doctest: +ELLIPSIS
Traceback (most recent call last):
ValueError: too many values to unpack...
>>> try: a,b,c = [1,2,3,4]
... except ValueError: pass
>>> failure_too_many([1,2,3,4])
Traceback (most recent call last):
ValueError: too many values to unpack (expected 3)
>>> a,b,c = [1,2,3,4] # doctest: +ELLIPSIS
Traceback (most recent call last):
ValueError: too many values to unpack...
>>> try: a,b,c = [1,2,3,4]
... except ValueError: pass
>>> failure_too_many((1,2,3,4))
Traceback (most recent call last):
ValueError: too many values to unpack (expected 3)
...
...
@@ -244,16 +239,14 @@ def failure_too_many(it):
def
failure_too_few
(
it
):
"""
>>> a,b,c = [1,2]
Traceback (most recent call last):
ValueError: need more than 2 values to unpack
>>> try: a,b,c = [1,2]
... except ValueError: pass
>>> failure_too_few([1,2])
Traceback (most recent call last):
ValueError: need more than 2 values to unpack
>>> a,b,c = (1,2)
Traceback (most recent call last):
ValueError: need more than 2 values to unpack
>>> try: a,b,c = (1,2)
... except ValueError: pass
>>> failure_too_few((1,2))
Traceback (most recent call last):
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