Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 37 additions & 31 deletions Lib/test/test_extcall.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@

>>> f(1, 2, 3, **{'a':4, 'b':5})
(1, 2, 3) {'a': 4, 'b': 5}
>>> f(1, 2, **{'a': -1, 'b': 5}, **{'a': 4, 'c': 6}) # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
>>> f(1, 2, **{'a': -1, 'b': 5}, **{'a': 4, 'c': 6})
Traceback (most recent call last):
...
TypeError: test.test_extcall.f() got multiple values for keyword argument 'a'
>>> f(1, 2, **{'a': -1, 'b': 5}, a=4, c=6) # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
>>> f(1, 2, **{'a': -1, 'b': 5}, a=4, c=6)
Traceback (most recent call last):
...
TypeError: test.test_extcall.f() got multiple values for keyword argument 'a'
>>> f(1, 2, a=3, **{'a': 4}, **{'a': 5}) # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
>>> f(1, 2, a=3, **{'a': 4}, **{'a': 5})
Traceback (most recent call last):
...
TypeError: test.test_extcall.f() got multiple values for keyword argument 'a'
Expand Down Expand Up @@ -134,7 +134,7 @@

>>> class Nothing: pass
...
>>> g(*Nothing()) # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
>>> g(*Nothing())
Traceback (most recent call last):
...
TypeError: test.test_extcall.g() argument after * must be an iterable, not Nothing
Expand All @@ -143,7 +143,7 @@
... def __len__(self): return 5
...

>>> g(*Nothing()) # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
>>> g(*Nothing())
Traceback (most recent call last):
...
TypeError: test.test_extcall.g() argument after * must be an iterable, not Nothing
Expand Down Expand Up @@ -263,75 +263,75 @@
...
TypeError: h() got an unexpected keyword argument 'e'

>>> h(*h) # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
>>> h(*h)
Traceback (most recent call last):
...
TypeError: test.test_extcall.h() argument after * must be an iterable, not function

>>> h(1, *h) # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
>>> h(1, *h)
Traceback (most recent call last):
...
TypeError: Value after * must be an iterable, not function

>>> h(*[1], *h) # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
>>> h(*[1], *h)
Traceback (most recent call last):
...
TypeError: Value after * must be an iterable, not function

>>> dir(*h) # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
>>> dir(*h)
Traceback (most recent call last):
...
TypeError: dir() argument after * must be an iterable, not function

>>> nothing = None
>>> nothing(*h) # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
>>> nothing(*h)
Traceback (most recent call last):
...
TypeError: None argument after * must be an iterable, \
not function

>>> h(**h) # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
>>> h(**h)
Traceback (most recent call last):
...
TypeError: test.test_extcall.h() argument after ** must be a mapping, not function

>>> h(**[]) # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
>>> h(**[])
Traceback (most recent call last):
...
TypeError: test.test_extcall.h() argument after ** must be a mapping, not list

>>> h(a=1, **h) # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
>>> h(a=1, **h)
Traceback (most recent call last):
...
TypeError: test.test_extcall.h() argument after ** must be a mapping, not function

>>> h(a=1, **[]) # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
>>> h(a=1, **[])
Traceback (most recent call last):
...
TypeError: test.test_extcall.h() argument after ** must be a mapping, not list

>>> h(**{'a': 1}, **h) # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
>>> h(**{'a': 1}, **h)
Traceback (most recent call last):
...
TypeError: test.test_extcall.h() argument after ** must be a mapping, not function

>>> h(**{'a': 1}, **[]) # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
>>> h(**{'a': 1}, **[])
Traceback (most recent call last):
...
TypeError: test.test_extcall.h() argument after ** must be a mapping, not list

>>> dir(**h) # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
>>> dir(**h)
Traceback (most recent call last):
...
TypeError: dir() argument after ** must be a mapping, not function

>>> nothing(**h) # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
>>> nothing(**h)
Traceback (most recent call last):
...
TypeError: None argument after ** must be a mapping, \
not function

>>> dir(b=1, **{'b': 1}) # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
>>> dir(b=1, **{'b': 1})
Traceback (most recent call last):
...
TypeError: dir() got multiple values for keyword argument 'b'
Expand Down Expand Up @@ -367,17 +367,17 @@
>>> g(**MultiDict([('x', 1), ('y', 2)]))
1 () {'y': 2}

>>> g(**MultiDict([('x', 1), ('x', 2)])) # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
>>> g(**MultiDict([('x', 1), ('x', 2)]))
Traceback (most recent call last):
...
TypeError: test.test_extcall.g() got multiple values for keyword argument 'x'

>>> g(a=3, **MultiDict([('x', 1), ('x', 2)])) # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
>>> g(a=3, **MultiDict([('x', 1), ('x', 2)]))
Traceback (most recent call last):
...
TypeError: test.test_extcall.g() got multiple values for keyword argument 'x'

>>> g(**MultiDict([('a', 3)]), **MultiDict([('x', 1), ('x', 2)])) # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
>>> g(**MultiDict([('a', 3)]), **MultiDict([('x', 1), ('x', 2)]))
Traceback (most recent call last):
...
TypeError: test.test_extcall.g() got multiple values for keyword argument 'x'
Expand All @@ -398,7 +398,7 @@
>>> assert s1(**md) == {'a': 1, 'b': 2}
>>> assert s2(*(1, 2), **md) == ((1, 2), {'a': 1, 'b': 2})
>>> assert s3(**MyDict({'n': 1, 'b': 2})) == (1, {'b': 2})
>>> s3(**md) # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
>>> s3(**md)
Traceback (most recent call last):
...
TypeError: s3() missing 1 required keyword-only argument: 'n'
Expand Down Expand Up @@ -442,7 +442,7 @@
... False
True

>>> id(1, **{'foo': 1}) # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
>>> id(1, **{'foo': 1}) # TODO: RUSTPYTHON # doctest:+EXPECTED_FAILURE
Traceback (most recent call last):
...
TypeError: id() takes no keyword arguments
Expand Down Expand Up @@ -484,17 +484,17 @@
...
TypeError: f() takes from 1 to 2 positional arguments but 3 were given
>>> def f(*, kw): pass
>>> f(1, kw=3) # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
>>> f(1, kw=3)
Traceback (most recent call last):
...
TypeError: f() takes 0 positional arguments but 1 positional argument (and 1 keyword-only argument) were given
>>> def f(*, kw, b): pass
>>> f(1, 2, 3, b=3, kw=3) # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
>>> f(1, 2, 3, b=3, kw=3)
Traceback (most recent call last):
...
TypeError: f() takes 0 positional arguments but 3 positional arguments (and 2 keyword-only arguments) were given
>>> def f(a, b=2, *, kw): pass
>>> f(2, 3, 4, kw=4) # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
>>> f(2, 3, 4, kw=4)
Traceback (most recent call last):
...
TypeError: f() takes from 1 to 2 positional arguments but 3 positional arguments (and 1 keyword-only argument) were given
Expand Down Expand Up @@ -530,12 +530,12 @@
Same with keyword only args:

>>> def f(*, w): pass
>>> f() # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
>>> f()
Traceback (most recent call last):
...
TypeError: f() missing 1 required keyword-only argument: 'w'
>>> def f(*, a, b, c, d, e): pass
>>> f() # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
>>> f()
Traceback (most recent call last):
...
TypeError: f() missing 5 required keyword-only arguments: 'a', 'b', 'c', 'd', and 'e'
Expand All @@ -545,9 +545,15 @@
import doctest
import unittest

EXPECTED_FAILURE = doctest.register_optionflag('EXPECTED_FAILURE') # TODO: RUSTPYTHON
class CustomOutputChecker(doctest.OutputChecker): # TODO: RUSTPYTHON
def check_output(self, want, got, optionflags): # TODO: RUSTPYTHON
if optionflags & EXPECTED_FAILURE: # TODO: RUSTPYTHON
return not super().check_output(want, got, optionflags) # TODO: RUSTPYTHON
return super().check_output(want, got, optionflags) # TODO: RUSTPYTHON

def load_tests(loader, tests, pattern):
from test.support.rustpython import DocTestChecker # TODO: RUSTPYTHON
tests.addTest(doctest.DocTestSuite(checker=DocTestChecker())) # XXX: RUSTPYTHON
tests.addTest(doctest.DocTestSuite(checker=CustomOutputChecker())) # TODO: RUSTPYTHON
return tests


Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_inspect/test_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -2247,7 +2247,6 @@ def test_varkw_only(self):
self.assertEqualCallArgs(f, '**collections.UserDict(a=1, b=2)')
self.assertEqualCallArgs(f, 'c=3, **collections.UserDict(a=1, b=2)')

@unittest.expectedFailure # TODO: RUSTPYTHON; ? ^^^^^^^^^^^^ ++ ++ ^^^^
def test_keyword_only(self):
f = self.makeCallable('a=3, *, c, d=2')
self.assertEqualCallArgs(f, 'c=3')
Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ def dumps(self, arg, proto=None, **kwargs):
def test_bad_newobj_args(self):
return super().test_bad_newobj_args()

@unittest.expectedFailure # TODO: RUSTPYTHON
def test_bad_newobj_ex_args(self):
return super().test_bad_newobj_ex_args()

Expand Down
2 changes: 0 additions & 2 deletions Lib/test/test_positional_only_arg.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ def f(a, b, /, c=3):
with self.assertRaisesRegex(TypeError, r"f\(\) takes from 2 to 3 positional arguments but 4 were given"):
f(1, 2, 3, 4)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_positional_only_and_kwonlyargs_invalid_calls(self):
def f(a, b, /, c, *, d, e):
pass
Expand Down
28 changes: 14 additions & 14 deletions Lib/test/test_unpack_ex.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
>>> sorted({**{'x': 1}, 'y': 2, **{'x': 3}}.items())
[('x', 3), ('y', 2)]

>>> sorted({**{'x': 1}, **{'x': 3}, 'x': 4}.items()) # TODO: RUSTPYTHON # doctest:+EXPECTED_FAILURE
>>> sorted({**{'x': 1}, **{'x': 3}, 'x': 4}.items())
[('x', 4)]

>>> {**{}}
Expand All @@ -138,7 +138,7 @@
... for i in range(1000)) + "}"))
1000

>>> {0:1, **{0:2}, 0:3, 0:4} # TODO: RUSTPYTHON # doctest:+EXPECTED_FAILURE
>>> {0:1, **{0:2}, 0:3, 0:4}
{0: 4}

List comprehension element unpacking
Expand Down Expand Up @@ -249,34 +249,34 @@

Overridden parameters

>>> f(x=5, **{'x': 3}, y=2) # TODO: RUSTPYTHON # doctest:+EXPECTED_FAILURE
>>> f(x=5, **{'x': 3}, y=2)
Traceback (most recent call last):
...
TypeError: test.test_unpack_ex.f() got multiple values for keyword argument 'x'

>>> f(**{'x': 3}, x=5, y=2) # TODO: RUSTPYTHON # doctest:+EXPECTED_FAILURE
>>> f(**{'x': 3}, x=5, y=2)
Traceback (most recent call last):
...
TypeError: test.test_unpack_ex.f() got multiple values for keyword argument 'x'

>>> f(**{'x': 3}, **{'x': 5}, y=2) # TODO: RUSTPYTHON # doctest:+EXPECTED_FAILURE
>>> f(**{'x': 3}, **{'x': 5}, y=2)
Traceback (most recent call last):
...
TypeError: test.test_unpack_ex.f() got multiple values for keyword argument 'x'

>>> f(x=5, **{'x': 3}, **{'x': 2}) # TODO: RUSTPYTHON # doctest:+EXPECTED_FAILURE
>>> f(x=5, **{'x': 3}, **{'x': 2})
Traceback (most recent call last):
...
TypeError: test.test_unpack_ex.f() got multiple values for keyword argument 'x'

>>> f(**{1: 3}, **{1: 5}) # TODO: RUSTPYTHON # doctest:+EXPECTED_FAILURE
>>> f(**{1: 3}, **{1: 5})
Traceback (most recent call last):
...
TypeError: test.test_unpack_ex.f() got multiple values for keyword argument '1'

Unpacking non-sequence

>>> a, *b = 7 # TODO: RUSTPYTHON # doctest:+EXPECTED_FAILURE
>>> a, *b = 7
Traceback (most recent call last):
...
TypeError: cannot unpack non-iterable int object
Expand Down Expand Up @@ -321,17 +321,17 @@

Now some general starred expressions (all fail).

>>> a, *b, c, *d, e = range(10) # TODO: RUSTPYTHON # doctest:+ELLIPSIS +EXPECTED_FAILURE
>>> a, *b, c, *d, e = range(10) # doctest:+ELLIPSIS
Traceback (most recent call last):
...
SyntaxError: multiple starred expressions in assignment

>>> [*b, *c] = range(10) # TODO: RUSTPYTHON # doctest:+ELLIPSIS +EXPECTED_FAILURE
>>> [*b, *c] = range(10) # doctest:+ELLIPSIS
Traceback (most recent call last):
...
SyntaxError: multiple starred expressions in assignment

>>> a,*b,*c,*d = range(4) # TODO: RUSTPYTHON # doctest:+ELLIPSIS +EXPECTED_FAILURE
>>> a,*b,*c,*d = range(4) # doctest:+ELLIPSIS
Traceback (most recent call last):
...
SyntaxError: multiple starred expressions in assignment
Expand All @@ -341,17 +341,17 @@
...
SyntaxError: starred assignment target must be in a list or tuple

>>> *a # TODO: RUSTPYTHON # doctest:+ELLIPSIS +EXPECTED_FAILURE
>>> *a # doctest:+ELLIPSIS
Traceback (most recent call last):
...
SyntaxError: can't use starred expression here

>>> *1 # TODO: RUSTPYTHON # doctest:+ELLIPSIS +EXPECTED_FAILURE
>>> *1 # doctest:+ELLIPSIS
Traceback (most recent call last):
...
SyntaxError: can't use starred expression here

>>> x = *a # TODO: RUSTPYTHON # doctest:+ELLIPSIS +EXPECTED_FAILURE
>>> x = *a # doctest:+ELLIPSIS
Traceback (most recent call last):
...
SyntaxError: can't use starred expression here
Expand Down
Loading
Loading