Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-45229: Make tkinter tests discoverable #28637

Merged
merged 1 commit into from
Oct 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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