Skip to content

Commit

Permalink
bpo-45229: Make tkinter tests discoverable (pythonGH-28637)
Browse files Browse the repository at this point in the history
(cherry picked from commit f59ed3c)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
  • Loading branch information
serhiy-storchaka authored and miss-islington committed Oct 13, 2021
1 parent 7e74d99 commit 195de49
Show file tree
Hide file tree
Showing 18 changed files with 498 additions and 606 deletions.
8 changes: 3 additions & 5 deletions Lib/test/test_tk.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
# Skip test if tk cannot be initialized.
support.requires('gui')

from tkinter.test import runtktests
def load_tests(loader, tests, pattern):
return loader.discover('tkinter.test.test_tkinter')

def test_main():
support.run_unittest(
*runtktests.get_tests(text=False, packages=['test_tkinter']))

if __name__ == '__main__':
test_main()
unittest.main()
41 changes: 21 additions & 20 deletions Lib/test/test_ttk_guionly.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,26 @@
import tkinter
from _tkinter import TclError
from tkinter import ttk
from tkinter.test import runtktests

root = None
try:
root = tkinter.Tk()
button = ttk.Button(root)
button.destroy()
del button
except TclError as msg:
# assuming ttk is not available
raise unittest.SkipTest("ttk not available: %s" % msg)
finally:
if root is not None:
root.destroy()
del root

def test_main():
support.run_unittest(
*runtktests.get_tests(text=False, packages=['test_ttk']))


def setUpModule():
root = None
try:
root = tkinter.Tk()
button = ttk.Button(root)
button.destroy()
del button
except TclError as msg:
# assuming ttk is not available
raise unittest.SkipTest("ttk not available: %s" % msg)
finally:
if root is not None:
root.destroy()
del root

def load_tests(loader, tests, pattern):
return loader.discover('tkinter.test.test_ttk')


if __name__ == '__main__':
test_main()
unittest.main()
Loading

0 comments on commit 195de49

Please sign in to comment.