summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_tcl.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-09-06 19:47:58 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-09-06 19:47:58 (GMT)
commit8f0a1d0f285536c9262d30b20f5f1becfe103309 (patch)
tree53491d67a7170e85b5d9f2c22f25e00ed5834162 /Lib/test/test_tcl.py
parentc70386ec16c373dc3c2b2778f12f1772985bd304 (diff)
downloadcpython-8f0a1d0f285536c9262d30b20f5f1becfe103309.zip
cpython-8f0a1d0f285536c9262d30b20f5f1becfe103309.tar.gz
cpython-8f0a1d0f285536c9262d30b20f5f1becfe103309.tar.bz2
Issue #22226: Added private function _splitdict() in the Tkinter module.
First letter no longer is stripped from the "status" key in the result of Treeview.heading().
Diffstat (limited to 'Lib/test/test_tcl.py')
-rw-r--r--Lib/test/test_tcl.py37
1 files changed, 36 insertions, 1 deletions
diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py
index 9e045da..7485e58 100644
--- a/Lib/test/test_tcl.py
+++ b/Lib/test/test_tcl.py
@@ -7,7 +7,7 @@ from test import support
_tkinter = support.import_module('_tkinter')
# Make sure tkinter._fix runs to set up the environment
-support.import_fresh_module('tkinter')
+tkinter = support.import_fresh_module('tkinter')
from tkinter import Tcl
from _tkinter import TclError
@@ -554,6 +554,41 @@ class TclTest(unittest.TestCase):
for arg, res in testcases:
self.assertEqual(split(arg), res, msg=arg)
+ def test_splitdict(self):
+ splitdict = tkinter._splitdict
+ tcl = self.interp.tk
+
+ arg = '-a {1 2 3} -something foo status {}'
+ self.assertEqual(splitdict(tcl, arg, False),
+ {'-a': '1 2 3', '-something': 'foo', 'status': ''})
+ self.assertEqual(splitdict(tcl, arg),
+ {'a': '1 2 3', 'something': 'foo', 'status': ''})
+
+ arg = ('-a', (1, 2, 3), '-something', 'foo', 'status', '{}')
+ self.assertEqual(splitdict(tcl, arg, False),
+ {'-a': (1, 2, 3), '-something': 'foo', 'status': '{}'})
+ self.assertEqual(splitdict(tcl, arg),
+ {'a': (1, 2, 3), 'something': 'foo', 'status': '{}'})
+
+ self.assertRaises(RuntimeError, splitdict, tcl, '-a b -c ')
+ self.assertRaises(RuntimeError, splitdict, tcl, ('-a', 'b', '-c'))
+
+ arg = tcl.call('list',
+ '-a', (1, 2, 3), '-something', 'foo', 'status', ())
+ self.assertEqual(splitdict(tcl, arg),
+ {'a': (1, 2, 3) if self.wantobjects else '1 2 3',
+ 'something': 'foo', 'status': ''})
+
+ if tcl_version >= (8, 5):
+ arg = tcl.call('dict', 'create',
+ '-a', (1, 2, 3), '-something', 'foo', 'status', ())
+ if not self.wantobjects or get_tk_patchlevel() < (8, 5, 5):
+ # Before 8.5.5 dicts were converted to lists through string
+ expected = {'a': '1 2 3', 'something': 'foo', 'status': ''}
+ else:
+ expected = {'a': (1, 2, 3), 'something': 'foo', 'status': ''}
+ self.assertEqual(splitdict(tcl, arg), expected)
+
class BigmemTclTest(unittest.TestCase):