| 1 |
import os.path |
| 2 |
import unittest |
| 3 |
from test import support |
| 4 |
from test.support import import_helper |
| 5 |
|
| 6 |
|
| 7 |
if support.check_sanitizer(address=True, memory=True): |
| 8 |
raise unittest.SkipTest("Tests involving libX11 can SEGFAULT on ASAN/MSAN builds") |
| 9 |
|
| 10 |
# Skip this test if _tkinter wasn't built. |
| 11 |
import_helper.import_module('_tkinter') |
| 12 |
|
| 13 |
# Skip test if tk cannot be initialized. |
| 14 |
support.requires('gui') |
| 15 |
|
| 16 |
|
| 17 |
import tkinter |
| 18 |
from _tkinter import TclError |
| 19 |
from tkinter import ttk |
| 20 |
|
| 21 |
|
| 22 |
def setUpModule(): |
| 23 |
wantobjects = support.get_resource_value('wantobjects') |
| 24 |
if wantobjects is not None: |
| 25 |
unittest.enterModuleContext( |
| 26 |
support.swap_attr(tkinter, 'wantobjects', int(wantobjects))) |
| 27 |
root = None |
| 28 |
try: |
| 29 |
root = tkinter.Tk() |
| 30 |
button = ttk.Button(root) |
| 31 |
button.destroy() |
| 32 |
del button |
| 33 |
except TclError as msg: |
| 34 |
# assuming ttk is not available |
| 35 |
raise unittest.SkipTest("ttk not available: %s" % msg) |
| 36 |
finally: |
| 37 |
if root is not None: |
| 38 |
root.destroy() |
| 39 |
del root |
| 40 |
|
| 41 |
|
| 42 |
def load_tests(*args): |
| 43 |
return support.load_package_tests(os.path.dirname(__file__), *args) |