diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-01-15 15:58:14 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-01-15 15:58:14 (GMT) |
commit | 1e2b7ee3e8b7040228e05c7ed38937bf6390c9b7 (patch) | |
tree | 7a76229b267d3b5e9fb1c85a848d89e7a451d9c4 /Lib/tkinter/test | |
parent | d94c554f7ddf29acbec8918bd53d93999cfd08a5 (diff) | |
parent | b1396523660ac74435976fcaa2d490f3124c6add (diff) | |
download | cpython-1e2b7ee3e8b7040228e05c7ed38937bf6390c9b7.zip cpython-1e2b7ee3e8b7040228e05c7ed38937bf6390c9b7.tar.gz cpython-1e2b7ee3e8b7040228e05c7ed38937bf6390c9b7.tar.bz2 |
Issue #15861: tkinter now correctly works with lists and tuples containing
strings with whitespaces, backslashes or unbalanced braces.
Diffstat (limited to 'Lib/tkinter/test')
-rw-r--r-- | Lib/tkinter/test/test_ttk/test_functions.py | 40 | ||||
-rw-r--r-- | Lib/tkinter/test/test_ttk/test_widgets.py | 8 |
2 files changed, 43 insertions, 5 deletions
diff --git a/Lib/tkinter/test/test_ttk/test_functions.py b/Lib/tkinter/test/test_ttk/test_functions.py index 2303e4c..0d8df16 100644 --- a/Lib/tkinter/test/test_ttk/test_functions.py +++ b/Lib/tkinter/test/test_ttk/test_functions.py @@ -49,13 +49,17 @@ class InternalFunctionsTest(unittest.TestCase): ttk._format_optdict({'test': {'left': 'as is'}}), {'-test': {'left': 'as is'}}) - # check script formatting and untouched value(s) + # check script formatting check_against( ttk._format_optdict( - {'test': [1, -1, '', '2m', 0], 'nochange1': 3, - 'nochange2': 'abc def'}, script=True), - {'-test': '{1 -1 {} 2m 0}', '-nochange1': 3, - '-nochange2': 'abc def' }) + {'test': [1, -1, '', '2m', 0], 'test2': 3, + 'test3': '', 'test4': 'abc def', + 'test5': '"abc"', 'test6': '{}', + 'test7': '} -spam {'}, script=True), + {'-test': '{1 -1 {} 2m 0}', '-test2': '3', + '-test3': '{}', '-test4': '{abc def}', + '-test5': '{"abc"}', '-test6': r'\{\}', + '-test7': r'\}\ -spam\ \{'}) opts = {'αβγ': True, 'á': False} orig_opts = opts.copy() @@ -69,6 +73,32 @@ class InternalFunctionsTest(unittest.TestCase): ttk._format_optdict( {'option': ('one two', 'three')}), {'-option': '{one two} three'}) + check_against( + ttk._format_optdict( + {'option': ('one\ttwo', 'three')}), + {'-option': '{one\ttwo} three'}) + + # passing empty strings inside a tuple/list + check_against( + ttk._format_optdict( + {'option': ('', 'one')}), + {'-option': '{} one'}) + + # passing values with braces inside a tuple/list + check_against( + ttk._format_optdict( + {'option': ('one} {two', 'three')}), + {'-option': r'one\}\ \{two three'}) + + # passing quoted strings inside a tuple/list + check_against( + ttk._format_optdict( + {'option': ('"one"', 'two')}), + {'-option': '{"one"} two'}) + check_against( + ttk._format_optdict( + {'option': ('{one}', 'two')}), + {'-option': r'\{one\} two'}) # ignore an option amount_opts = len(ttk._format_optdict(opts, ignore=('á'))) / 2 diff --git a/Lib/tkinter/test/test_ttk/test_widgets.py b/Lib/tkinter/test/test_ttk/test_widgets.py index f5c0f17..c2231dc 100644 --- a/Lib/tkinter/test/test_ttk/test_widgets.py +++ b/Lib/tkinter/test/test_ttk/test_widgets.py @@ -189,6 +189,14 @@ class ComboboxTest(unittest.TestCase): self.combo.configure(values=[1, '', 2]) self.assertEqual(self.combo['values'], ('1', '', '2')) + # testing values with spaces + self.combo['values'] = ['a b', 'a\tb', 'a\nb'] + self.assertEqual(self.combo['values'], ('a b', 'a\tb', 'a\nb')) + + # testing values with special characters + self.combo['values'] = [r'a\tb', '"a"', '} {'] + self.assertEqual(self.combo['values'], (r'a\tb', '"a"', '} {')) + # out of range self.assertRaises(tkinter.TclError, self.combo.current, len(self.combo['values'])) |