Commit a5f77c7f authored by Stefan Behnel's avatar Stefan Behnel

adapted doctests to PyPy

parent 59782372
...@@ -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})
...@@ -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
......
...@@ -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)
...@@ -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):
......
...@@ -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
...@@ -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
......
...@@ -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
......
...@@ -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
......
...@@ -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
......
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