Commit a5f77c7f authored by Stefan Behnel's avatar Stefan Behnel

adapted doctests to PyPy

parent 59782372
......@@ -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})
......@@ -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
......
......@@ -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)
......@@ -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):
......
......@@ -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
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment