klappnase added the comment: I am not familiar with python's test unit, but I tried my best.
As far as I see there are three possibilities to invoke the function: * without pattern -> return tuple with all themes * with pattern that matches one or more themes * with pattern that matches no themes -> return empty tuple So I tried to add a method to test_style.StyleTest() : def test_themes(self): installed_themes = self.style.themes() some_themes = self.style.themes('*e*') no_themes = self.style.themes('foobarbaz') self.assertTrue(isinstance(installed_themes, tuple)) self.assertTrue(isinstance(some_themes, tuple)) self.assertTrue(isinstance(no_themes, tuple)) Oddly enough this fails on my own system (debian squeeze, tk-8.5.8, python-3.1.3 / -2.6.6): $ python3 test_style.py test_configure (__main__.StyleTest) ... ok test_layout (__main__.StyleTest) ... ok test_lookup (__main__.StyleTest) ... ok test_map (__main__.StyleTest) ... ok test_theme_use (__main__.StyleTest) ... ok test_themes (__main__.StyleTest) ... ERROR ====================================================================== ERROR: test_themes (__main__.StyleTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "test_style.py", line 97, in test_themes no_themes = self.style.themes('foobarbaz') File "/usr/lib/python3.1/tkinter/ttk.py", line 536, in themes return self.tk.splitlist(self.tk.call('ttk::themes', pattern)) TypeError: Can't convert '_tkinter.Tcl_Obj' object to str implicitly ---------------------------------------------------------------------- Ran 6 tests in 0.086s FAILED (errors=1) Traceback (most recent call last): File "test_style.py", line 108, in <module> run_unittest(*tests_gui) File "/usr/lib/python3.1/test/support.py", line 955, in run_unittest _run_suite(suite) File "/usr/lib/python3.1/test/support.py", line 938, in _run_suite raise TestFailed(err) test.support.TestFailed: Traceback (most recent call last): File "test_style.py", line 97, in test_themes no_themes = self.style.themes('foobarbaz') File "/usr/lib/python3.1/tkinter/ttk.py", line 536, in themes return self.tk.splitlist(self.tk.call('ttk::themes', pattern)) TypeError: Can't convert '_tkinter.Tcl_Obj' object to str implicitly The same error occurs with python-2.6.6 (same tk). Apparently this is because: $ python3 Python 3.1.3 (r313:86834, Nov 28 2010, 11:28:10) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from tkinter import * >>> from tkinter import ttk >>> r=Tk() >>> s=ttk.Style() >>> x = s.themes('foo') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3.1/tkinter/ttk.py", line 536, in themes return self.tk.splitlist(self.tk.call('ttk::themes', pattern)) TypeError: Can't convert '_tkinter.Tcl_Obj' object to str implicitly >>> x=r.tk.call('ttk::themes', 'foo') >>> x <StateSpec object at 0x9b1b6c8> >>> str(x) '' >>> Called from wish the same call returns an empty string as expected: $ wish % ttk::themes classic default clam alt % ttk::themes *e* default % ttk::themes foobarbaz % In python2.6, when setting Tkinter.wantobjects to 0, themes('foo') returns an empty tuple as expected. So I guess this is due to a bug in debian's python/tkinter install. Can anyone confirm this? ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue17397> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com