ยปCore Development>Code coverage>Lib/test/test_ttk_guionly.py

Python code coverage for Lib/test/test_ttk_guionly.py

#countcontent
1n/aimport unittest
2n/afrom test import support
3n/a
4n/a# Skip this test if _tkinter wasn't built.
5n/asupport.import_module('_tkinter')
6n/a
7n/a# Skip test if tk cannot be initialized.
8n/asupport.requires('gui')
9n/a
10n/aimport tkinter
11n/afrom _tkinter import TclError
12n/afrom tkinter import ttk
13n/afrom tkinter.test import runtktests
14n/a
15n/aroot = None
16n/atry:
17n/a root = tkinter.Tk()
18n/a button = ttk.Button(root)
19n/a button.destroy()
20n/a del button
21n/aexcept TclError as msg:
22n/a # assuming ttk is not available
23n/a raise unittest.SkipTest("ttk not available: %s" % msg)
24n/afinally:
25n/a if root is not None:
26n/a root.destroy()
27n/a del root
28n/a
29n/adef test_main():
30n/a support.run_unittest(
31n/a *runtktests.get_tests(text=False, packages=['test_ttk']))
32n/a
33n/aif __name__ == '__main__':
34n/a test_main()