Skip to content

Update test_tuple.py from 3.13.5 #5966

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 14, 2025
Merged
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
29 changes: 29 additions & 0 deletions Lib/test/test_tuple.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,35 @@ def test_keyword_args(self):
with self.assertRaisesRegex(TypeError, 'keyword argument'):
tuple(sequence=())

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_keywords_in_subclass(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you are interested in, Constructor for PyTuple probably is a point to start fix this issue

class subclass(tuple):
pass
u = subclass([1, 2])
self.assertIs(type(u), subclass)
self.assertEqual(list(u), [1, 2])
with self.assertRaises(TypeError):
subclass(sequence=())

class subclass_with_init(tuple):
def __init__(self, arg, newarg=None):
self.newarg = newarg
u = subclass_with_init([1, 2], newarg=3)
self.assertIs(type(u), subclass_with_init)
self.assertEqual(list(u), [1, 2])
self.assertEqual(u.newarg, 3)

class subclass_with_new(tuple):
def __new__(cls, arg, newarg=None):
self = super().__new__(cls, arg)
self.newarg = newarg
return self
u = subclass_with_new([1, 2], newarg=3)
self.assertIs(type(u), subclass_with_new)
self.assertEqual(list(u), [1, 2])
self.assertEqual(u.newarg, 3)

def test_truth(self):
super().test_truth()
self.assertTrue(not ())
Expand Down
Loading