[Python-checkins] r85065 - python/branches/release27-maint-ttk-debug-on-xp5/Lib/lib-tk/test/test_ttk/test_extensions.py
hirokazu.yamamoto
python-checkins at python.org
Tue Sep 28 17:02:30 CEST 2010
Author: hirokazu.yamamoto
Date: Tue Sep 28 17:02:30 2010
New Revision: 85065
Log:
Hmm, thread.interrupt_main cannot interrupt test_ttk_guionly.
Try another method. Use sys.settrace to trace main thread.
Modified:
python/branches/release27-maint-ttk-debug-on-xp5/Lib/lib-tk/test/test_ttk/test_extensions.py
Modified: python/branches/release27-maint-ttk-debug-on-xp5/Lib/lib-tk/test/test_ttk/test_extensions.py
==============================================================================
--- python/branches/release27-maint-ttk-debug-on-xp5/Lib/lib-tk/test/test_ttk/test_extensions.py (original)
+++ python/branches/release27-maint-ttk-debug-on-xp5/Lib/lib-tk/test/test_ttk/test_extensions.py Tue Sep 28 17:02:30 2010
@@ -2,6 +2,7 @@
import unittest
import Tkinter
import ttk
+import collections
import threading
import thread
import time
@@ -11,6 +12,10 @@
requires('gui')
+CODES_SIZE = 100
+WAIT = 10 * 60 # XXX: adjust here
+
+
class LabeledScaleTest(unittest.TestCase):
def setUp(self):
@@ -107,13 +112,6 @@
def test_horizontal_range(self):
- def func():
- time.sleep(60 * 5) # XXX: adjust here
- thread.interrupt_main()
-
- t = threading.Thread(target=func)
- t.start()
-
lscale = ttk.LabeledScale(from_=0, to=10)
lscale.pack()
lscale.wait_visibility()
@@ -142,7 +140,6 @@
lscale.destroy()
- t.join()
def _test_variable_change(self):
x = ttk.LabeledScale()
@@ -283,4 +280,21 @@
tests_gui = (LabeledScaleTest,)
if __name__ == "__main__":
- run_unittest(*tests_gui)
+ codes = collections.deque([None] * CODES_SIZE)
+ def tracefunc(frame, event, arg):
+ codes.append(frame.f_code)
+ codes.popleft()
+ sys.settrace(tracefunc) # only main thread now
+
+ def threadfunc():
+ time.sleep(WAIT)
+ for code in codes:
+ if code is None:
+ continue
+ print(code)
+ t = threading.Thread(target=threadfunc)
+ t.start()
+ try:
+ run_unittest(*tests_gui)
+ finally:
+ t.join()
More information about the Python-checkins
mailing list