@@ -70,6 +70,12 @@ class BadInt3(int):
7070 def __int__ (self ):
7171 return True
7272
73+ class TupleSubclass (tuple ):
74+ pass
75+
76+ class DictSubclass (dict ):
77+ pass
78+
7379
7480class Unsigned_TestCase (unittest .TestCase ):
7581 def test_b (self ):
@@ -321,6 +327,33 @@ def test_p(self):
321327
322328
323329class Tuple_TestCase (unittest .TestCase ):
330+ def test_args (self ):
331+ from _testcapi import get_args
332+
333+ ret = get_args (1 , 2 )
334+ self .assertEqual (ret , (1 , 2 ))
335+ self .assertIs (type (ret ), tuple )
336+
337+ ret = get_args (1 , * (2 , 3 ))
338+ self .assertEqual (ret , (1 , 2 , 3 ))
339+ self .assertIs (type (ret ), tuple )
340+
341+ ret = get_args (* [1 , 2 ])
342+ self .assertEqual (ret , (1 , 2 ))
343+ self .assertIs (type (ret ), tuple )
344+
345+ ret = get_args (* TupleSubclass ([1 , 2 ]))
346+ self .assertEqual (ret , (1 , 2 ))
347+ self .assertIsInstance (ret , tuple )
348+
349+ ret = get_args ()
350+ self .assertIn (ret , ((), None ))
351+ self .assertIn (type (ret ), (tuple , type (None )))
352+
353+ ret = get_args (* ())
354+ self .assertIn (ret , ((), None ))
355+ self .assertIn (type (ret ), (tuple , type (None )))
356+
324357 def test_tuple (self ):
325358 from _testcapi import getargs_tuple
326359
@@ -336,6 +369,29 @@ def __getitem__(self, n):
336369 self .assertRaises (TypeError , getargs_tuple , 1 , seq ())
337370
338371class Keywords_TestCase (unittest .TestCase ):
372+ def test_kwargs (self ):
373+ from _testcapi import get_kwargs
374+
375+ ret = get_kwargs (a = 1 , b = 2 )
376+ self .assertEqual (ret , {'a' : 1 , 'b' : 2 })
377+ self .assertIs (type (ret ), dict )
378+
379+ ret = get_kwargs (a = 1 , ** {'b' : 2 , 'c' : 3 })
380+ self .assertEqual (ret , {'a' : 1 , 'b' : 2 , 'c' : 3 })
381+ self .assertIs (type (ret ), dict )
382+
383+ ret = get_kwargs (** DictSubclass ({'a' : 1 , 'b' : 2 }))
384+ self .assertEqual (ret , {'a' : 1 , 'b' : 2 })
385+ self .assertIsInstance (ret , dict )
386+
387+ ret = get_kwargs ()
388+ self .assertIn (ret , ({}, None ))
389+ self .assertIn (type (ret ), (dict , type (None )))
390+
391+ ret = get_kwargs (** {})
392+ self .assertIn (ret , ({}, None ))
393+ self .assertIn (type (ret ), (dict , type (None )))
394+
339395 def test_positional_args (self ):
340396 # using all positional args
341397 self .assertEqual (
0 commit comments