cpython: 118e427808ce (original) (raw)

Mercurial > cpython

changeset 90984:118e427808ce

Issue #18492: Merge with 3.4 [#18492]

Zachary Ware zachary.ware@gmail.com
date Mon, 02 Jun 2014 16:04:25 -0500
parents dff6b4b61cac(current diff)8519576b0dc5(diff)
children 0ee47d3d2664
files Lib/test/test_decimal.py Misc/NEWS
diffstat 14 files changed, 37 insertions(+), 59 deletions(-)[+] [-] Lib/idlelib/FormatParagraph.py 1 Lib/idlelib/IdleHistory.py 2 Lib/idlelib/SearchEngine.py 1 Lib/idlelib/idle_test/README.txt 37 Lib/test/support/__init__.py 20 Lib/test/test_codecmaps_hk.py 1 Lib/test/test_decimal.py 4 Lib/test/test_idle.py 4 Lib/test/test_imaplib.py 1 Lib/test/test_robotparser.py 1 Lib/test/test_tk.py 10 Lib/test/test_ttk_guionly.py 10 Lib/tkinter/test/runtktests.py 1 Misc/NEWS 3

line wrap: on

line diff

--- a/Lib/idlelib/FormatParagraph.py +++ b/Lib/idlelib/FormatParagraph.py @@ -188,7 +188,6 @@ def get_comment_header(line): return m.group(1) if name == "main":

--- a/Lib/idlelib/IdleHistory.py +++ b/Lib/idlelib/IdleHistory.py @@ -100,7 +100,5 @@ class History: self.prefix = None if name == "main":

--- a/Lib/idlelib/SearchEngine.py +++ b/Lib/idlelib/SearchEngine.py @@ -229,6 +229,5 @@ def get_line_col(index): return line, col if name == "main":

--- a/Lib/idlelib/idle_test/README.txt +++ b/Lib/idlelib/idle_test/README.txt @@ -26,7 +26,6 @@ Once test_xyy is written, the following with xyz (lowercased) added after 'test_'. --- if name == "main":

  1. Gui Tests

-Gui tests need 'requires' and 'use_resources' from test.support -(test.test_support in 2.7). A test is a gui test if it creates a Tk root or -master object either directly or indirectly by instantiating a tkinter or -idle class. For the benefit of buildbot machines that do not have a graphics -screen, gui tests must be 'guarded' by "requires('gui')" in a setUp -function or method. This will typically be setUpClass. +Gui tests need 'requires' from test.support (test.test_support in 2.7). A +test is a gui test if it creates a Tk root or master object either directly +or indirectly by instantiating a tkinter or idle class. For the benefit of +test processes that either have no graphical environment available or are not +allowed to use it, gui tests must be 'guarded' by "requires('gui')" in a +setUp function or method. This will typically be setUpClass. To avoid interfering with other gui tests, all gui objects must be destroyed and deleted by the end of the test. If a widget, such as a Tk root, is created @@ -57,11 +56,17 @@ and class attributes, also delete the wi del cls.root --- -Support.requires('gui') returns true if it is either called in a main module -(which never happens on buildbots) or if use_resources contains 'gui'. -Use_resources is set by test.regrtest but not by unittest. So when running -tests in another module with unittest, we set it ourselves, as in the xyz.py -template above. +Support.requires('gui') causes the test(s) it guards to be skipped if any of +a few conditions are met:

Since non-gui tests always run, but gui tests only sometimes, tests of non-gui operations should best avoid needing a gui. Methods that make incidental use of @@ -88,8 +93,8 @@ python -m idlelib.idle_test.test_xyz To run all idle_test/test_*.py tests, either interactively ('>>>', with unittest imported) or from a command line, use one of the -following. (Notes: unittest does not run gui tests; in 2.7, 'test ' (with the -space) is 'test.regrtest '; where present, -v and -ugui can be omitted.) +following. (Notes: in 2.7, 'test ' (with the space) is 'test.regrtest '; +where present, -v and -ugui can be omitted.)

unittest.main('idlelib.idle_test', verbosity=2, exit=False) python -m unittest -v idlelib.idle_test @@ -98,13 +103,13 @@ python -m test.test_idle The idle tests are 'discovered' by idlelib.idle_test.init.load_tests, which is also imported into test.test_idle. Normally, neither file should be -changed when working on individual test modules. The third command runs runs +changed when working on individual test modules. The third command runs unittest indirectly through regrtest. The same happens when the entire test suite is run with 'python -m test'. So that command must work for buildbots to stay green. Idle tests must not disturb the environment in a way that makes other tests fail (issue 18081). To run an individual Testcase or test method, extend the dotted name given to -unittest on the command line. (But gui tests will not this way.) +unittest on the command line. python -m unittest -v idlelib.idle_test.test_xyz.Test_case.test_meth

--- a/Lib/test/support/init.py +++ b/Lib/test/support/init.py @@ -454,23 +454,17 @@ def _is_gui_available(): return _is_gui_available.result def is_resource_enabled(resource):

+

def requires(resource, msg=None):

-

--- a/Lib/test/test_codecmaps_hk.py +++ b/Lib/test/test_codecmaps_hk.py @@ -16,5 +16,4 @@ def test_main(): support.run_unittest(name) if name == "main":

--- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -5556,7 +5556,7 @@ else: all_tests.insert(1, SignatureTest) -def test_main(arith=False, verbose=None, todo_tests=None, debug=None): +def test_main(arith=None, verbose=None, todo_tests=None, debug=None): """ Execute the tests. Runs all arithmetic tests if arith is True or if the "decimal" resource @@ -5566,7 +5566,7 @@ def test_main(arith=False, verbose=None, init(C) init(P) global TEST_ALL, DEBUG

--- a/Lib/test/test_idle.py +++ b/Lib/test/test_idle.py @@ -13,8 +13,4 @@ idletest = import_module('idlelib.idle_t load_tests = idletest.load_tests if name == 'main':

--- a/Lib/test/test_imaplib.py +++ b/Lib/test/test_imaplib.py @@ -501,5 +501,4 @@ def load_tests(*args): if name == "main":

--- a/Lib/test/test_robotparser.py +++ b/Lib/test/test_robotparser.py @@ -291,5 +291,4 @@ def load_tests(loader, suite, pattern): return suite if name=='main':

--- a/Lib/test/test_tk.py +++ b/Lib/test/test_tk.py @@ -10,15 +10,9 @@ support.requires('gui') from tkinter.test import runtktests -def test_main(enable_gui=False):

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

--- a/Lib/test/test_ttk_guionly.py +++ b/Lib/test/test_ttk_guionly.py @@ -22,13 +22,7 @@ except TclError as msg: # assuming ttk is not available raise unittest.SkipTest("ttk not available: %s" % msg) -def test_main(enable_gui=False):

- +def test_main(): try: support.run_unittest( *runtktests.get_tests(text=False, packages=['test_ttk'])) @@ -36,4 +30,4 @@ def test_main(enable_gui=False): get_tk_root().destroy() if name == 'main':

--- a/Lib/tkinter/test/runtktests.py +++ b/Lib/tkinter/test/runtktests.py @@ -68,5 +68,4 @@ def get_tests(text=True, gui=True, packa yield test if name == "main":

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -531,6 +531,9 @@ Documentation Tests ----- +- Issue #18492: All resources are now allowed when tests are not run by