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

Class TkTestRunner

Tools/unittestgui/unittestgui.py:244–430  ·  view source on GitHub ↗

An implementation of BaseGUITestRunner using Tkinter.

Source from the content-addressed store, hash-verified

242 self.test_file_glob_pattern = self.testPatternVar.get()
243
244class TkTestRunner(BaseGUITestRunner):
245 """An implementation of BaseGUITestRunner using Tkinter.
246 """
247 def initGUI(self, root, initialTestName):
248 """Set up the GUI inside the given root window. The test name entry
249 field will be pre-filled with the given initialTestName.
250 """
251 self.root = root
252
253 self.statusVar = tk.StringVar()
254 self.statusVar.set("Idle")
255
256 #tk vars for tracking counts of test result types
257 self.runCountVar = tk.IntVar()
258 self.failCountVar = tk.IntVar()
259 self.errorCountVar = tk.IntVar()
260 self.skipCountVar = tk.IntVar()
261 self.expectFailCountVar = tk.IntVar()
262 self.remainingCountVar = tk.IntVar()
263
264 self.top = tk.Frame()
265 self.top.pack(fill=tk.BOTH, expand=1)
266 self.createWidgets()
267
268 def getDirectoryToDiscover(self):
269 return filedialog.askdirectory()
270
271 def settingsClicked(self):
272 d = DiscoverSettingsDialog(self.top, self.top_level_dir, self.test_file_glob_pattern)
273 self.top_level_dir = d.top_level_dir
274 self.test_file_glob_pattern = d.test_file_glob_pattern
275
276 def notifyTestsDiscovered(self, test_suite):
277 discovered = test_suite.countTestCases()
278 self.runCountVar.set(0)
279 self.failCountVar.set(0)
280 self.errorCountVar.set(0)
281 self.remainingCountVar.set(discovered)
282 self.progressBar.setProgressFraction(0.0)
283 self.errorListbox.delete(0, tk.END)
284 self.statusVar.set("Discovering tests from %s. Found: %s" %
285 (self.directory_to_read, discovered))
286 self.stopGoButton['state'] = tk.NORMAL
287
288 def createWidgets(self):
289 """Creates and packs the various widgets.
290
291 Why is it that GUI code always ends up looking a mess, despite all the
292 best intentions to keep it tidy? Answers on a postcard, please.
293 """
294 # Status bar
295 statusFrame = tk.Frame(self.top, relief=tk.SUNKEN, borderwidth=2)
296 statusFrame.pack(anchor=tk.SW, fill=tk.X, side=tk.BOTTOM)
297 tk.Label(statusFrame, width=1, textvariable=self.statusVar).pack(side=tk.TOP, fill=tk.X)
298
299 # Area to enter name of test to run
300 leftFrame = tk.Frame(self.top, borderwidth=3)
301 leftFrame.pack(fill=tk.BOTH, side=tk.LEFT, anchor=tk.NW, expand=1)

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by 1

mainFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…