MCPcopy Index your code
hub / github.com/python/cpython / test_splitlist

Method test_splitlist

Lib/test/test_tcl.py:645–691  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

643 self.assertEqual(a, expected)
644
645 def test_splitlist(self):
646 splitlist = self.interp.tk.splitlist
647 call = self.interp.tk.call
648 self.assertRaises(TypeError, splitlist)
649 self.assertRaises(TypeError, splitlist, 'a', 'b')
650 self.assertRaises(TypeError, splitlist, 2)
651 testcases = [
652 ('2', ('2',)),
653 ('', ()),
654 ('{}', ('',)),
655 ('""', ('',)),
656 ('a\n b\t\r c\n ', ('a', 'b', 'c')),
657 (b'a\n b\t\r c\n ', ('a', 'b', 'c')),
658 ('a \u20ac', ('a', '\u20ac')),
659 ('a \U0001f4bb', ('a', '\U0001f4bb')),
660 (b'a \xe2\x82\xac', ('a', '\u20ac')),
661 (b'a \xf0\x9f\x92\xbb', ('a', '\U0001f4bb')),
662 (b'a \xed\xa0\xbd\xed\xb2\xbb', ('a', '\U0001f4bb')),
663 (b'a\xc0\x80b c\xc0\x80d', ('a\x00b', 'c\x00d')),
664 ('a {b c}', ('a', 'b c')),
665 (r'a b\ c', ('a', 'b c')),
666 (('a', 'b c'), ('a', 'b c')),
667 ('a 2', ('a', '2')),
668 (('a', 2), ('a', 2)),
669 ('a 3.4', ('a', '3.4')),
670 (('a', 3.4), ('a', 3.4)),
671 ((), ()),
672 ([], ()),
673 (['a', ['b', 'c']], ('a', ['b', 'c'])),
674 (call('list', 1, '2', (3.4,)),
675 (1, '2', (3.4,)) if self.wantobjects else
676 ('1', '2', '3.4')),
677 ]
678 if not self.wantobjects:
679 expected = ('12', '\u20ac', '\xe2\x82\xac', '3.4')
680 else:
681 expected = (12, '\u20ac', b'\xe2\x82\xac', (3.4,))
682 testcases += [
683 (call('dict', 'create', 12, '\u20ac', b'\xe2\x82\xac', (3.4,)),
684 expected),
685 ]
686 dbg_info = ('want objects? %s, Tcl version: %s, Tcl patchlevel: %s'
687 % (self.wantobjects, tcl_version, self.interp.info_patchlevel()))
688 for arg, res in testcases:
689 self.assertEqual(splitlist(arg), res,
690 'arg=%a, %s' % (arg, dbg_info))
691 self.assertRaises(TclError, splitlist, '{')
692
693 def test_splitdict(self):
694 splitdict = tkinter._splitdict

Callers

nothing calls this directly

Calls 4

info_patchlevelMethod · 0.80
callFunction · 0.70
assertRaisesMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected