summaryrefslogtreecommitdiffstats
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/pythonrun.c')
0 files changed, 0 insertions, 0 deletions
test/test_commands.py | 2 +- Lib/test/test_compare.py | 4 +- Lib/test/test_compile.py | 4 +- Lib/test/test_complex.py | 10 +- Lib/test/test_contains.py | 2 +- Lib/test/test_contextlib.py | 4 +- Lib/test/test_cookie.py | 2 +- Lib/test/test_cookielib.py | 14 +- Lib/test/test_copy.py | 8 +- Lib/test/test_copyreg.py | 4 +- Lib/test/test_crypt.py | 6 +- Lib/test/test_csv.py | 6 +- Lib/test/test_ctypes.py | 2 +- Lib/test/test_curses.py | 2 +- Lib/test/test_datetime.py | 4 +- Lib/test/test_dbm.py | 8 +- Lib/test/test_decimal.py | 2 +- Lib/test/test_decorators.py | 6 +- Lib/test/test_defaultdict.py | 4 +- Lib/test/test_deque.py | 30 +- Lib/test/test_descr.py | 10 +- Lib/test/test_descrtut.py | 6 +- Lib/test/test_dict.py | 4 +- Lib/test/test_dictcomps.py | 6 +- Lib/test/test_dictviews.py | 4 +- Lib/test/test_difflib.py | 2 +- Lib/test/test_dis.py | 2 +- Lib/test/test_distutils.py | 4 +- Lib/test/test_doctest.py | 6 +- Lib/test/test_doctest2.py | 6 +- Lib/test/test_docxmlrpc.py | 4 +- Lib/test/test_dumbdbm.py | 6 +- Lib/test/test_dummy_thread.py | 14 +- Lib/test/test_dummy_threading.py | 16 +- Lib/test/test_email.py | 4 +- Lib/test/test_enumerate.py | 6 +- Lib/test/test_eof.py | 8 +- Lib/test/test_epoll.py | 8 +- Lib/test/test_errno.py | 4 +- Lib/test/test_exception_variations.py | 2 +- Lib/test/test_exceptions.py | 2 +- Lib/test/test_extcall.py | 8 +- Lib/test/test_fcntl.py | 2 +- Lib/test/test_file.py | 2 +- Lib/test/test_filecmp.py | 10 +- Lib/test/test_fileinput.py | 4 +- Lib/test/test_fileio.py | 2 +- Lib/test/test_float.py | 6 +- Lib/test/test_fnmatch.py | 4 +- Lib/test/test_fork1.py | 2 +- Lib/test/test_format.py | 8 +- Lib/test/test_fractions.py | 2 +- Lib/test/test_frozen.py | 2 +- Lib/test/test_ftplib.py | 8 +- Lib/test/test_funcattrs.py | 4 +- Lib/test/test_functools.py | 6 +- Lib/test/test_future.py | 10 +- Lib/test/test_future3.py | 4 +- Lib/test/test_future4.py | 2 +- Lib/test/test_gc.py | 2 +- Lib/test/test_gdbm.py | 2 +- Lib/test/test_generators.py | 4 +- Lib/test/test_genericpath.py | 92 ++-- Lib/test/test_genexps.py | 6 +- Lib/test/test_getargs2.py | 4 +- Lib/test/test_getopt.py | 2 +- Lib/test/test_gettext.py | 4 +- Lib/test/test_glob.py | 2 +- Lib/test/test_global.py | 2 +- Lib/test/test_grammar.py | 2 +- Lib/test/test_grp.py | 4 +- Lib/test/test_gzip.py | 10 +- Lib/test/test_hash.py | 4 +- Lib/test/test_hashlib.py | 4 +- Lib/test/test_heapq.py | 6 +- Lib/test/test_hmac.py | 6 +- Lib/test/test_htmllib.py | 4 +- Lib/test/test_htmlparser.py | 4 +- Lib/test/test_httplib.py | 8 +- Lib/test/test_imaplib.py | 4 +- Lib/test/test_imp.py | 4 +- Lib/test/test_import.py | 12 +- Lib/test/test_importhooks.py | 4 +- Lib/test/test_index.py | 6 +- Lib/test/test_inspect.py | 2 +- Lib/test/test_int.py | 2 +- Lib/test/test_int_literal.py | 4 +- Lib/test/test_io.py | 70 +-- Lib/test/test_ioctl.py | 2 +- Lib/test/test_isinstance.py | 4 +- Lib/test/test_iter.py | 2 +- Lib/test/test_iterlen.py | 4 +- Lib/test/test_itertools.py | 10 +- Lib/test/test_json.py | 6 +- Lib/test/test_keywordonlyarg.py | 2 +- Lib/test/test_kqueue.py | 6 +- Lib/test/test_largefile.py | 2 +- Lib/test/test_lib2to3.py | 2 +- Lib/test/test_list.py | 6 +- Lib/test/test_listcomps.py | 18 +- Lib/test/test_locale.py | 2 +- Lib/test/test_logging.py | 2 +- Lib/test/test_long.py | 4 +- Lib/test/test_long_future.py | 2 +- Lib/test/test_longexp.py | 4 +- Lib/test/test_macpath.py | 4 +- Lib/test/test_mailbox.py | 28 +- Lib/test/test_marshal.py | 10 +- Lib/test/test_math.py | 2 +- Lib/test/test_memoryio.py | 4 +- Lib/test/test_memoryview.py | 4 +- Lib/test/test_metaclass.py | 4 +- Lib/test/test_mimetools.py | 4 +- Lib/test/test_mimetypes.py | 4 +- Lib/test/test_minidom.py | 2 +- Lib/test/test_mmap.py | 2 +- Lib/test/test_module.py | 2 +- Lib/test/test_modulefinder.py | 4 +- Lib/test/test_multibytecodec.py | 10 +- Lib/test/test_multibytecodec_support.py | 6 +- Lib/test/test_mutants.py | 2 +- Lib/test/test_netrc.py | 6 +- Lib/test/test_nis.py | 6 +- Lib/test/test_normalization.py | 2 +- Lib/test/test_ntpath.py | 6 +- Lib/test/test_opcodes.py | 2 +- Lib/test/test_openpty.py | 2 +- Lib/test/test_operator.py | 6 +- Lib/test/test_optparse.py | 28 +- Lib/test/test_os.py | 68 +-- Lib/test/test_ossaudiodev.py | 8 +- Lib/test/test_parser.py | 4 +- Lib/test/test_peepholer.py | 6 +- Lib/test/test_pep247.py | 4 +- Lib/test/test_pep263.py | 4 +- Lib/test/test_pep277.py | 26 +- Lib/test/test_pep292.py | 4 +- Lib/test/test_pep3120.py | 4 +- Lib/test/test_pep3131.py | 4 +- Lib/test/test_pep352.py | 2 +- Lib/test/test_pickle.py | 6 +- Lib/test/test_pickletools.py | 6 +- Lib/test/test_pipes.py | 2 +- Lib/test/test_pkg.py | 4 +- Lib/test/test_pkgimport.py | 2 +- Lib/test/test_pkgutil.py | 2 +- Lib/test/test_platform.py | 4 +- Lib/test/test_plistlib.py | 10 +- Lib/test/test_poll.py | 2 +- Lib/test/test_popen.py | 6 +- Lib/test/test_poplib.py | 8 +- Lib/test/test_posix.py | 80 +-- Lib/test/test_posixpath.py | 134 ++--- Lib/test/test_pow.py | 4 +- Lib/test/test_pprint.py | 4 +- Lib/test/test_print.py | 6 +- Lib/test/test_profile.py | 2 +- Lib/test/test_profilehooks.py | 6 +- Lib/test/test_property.py | 2 +- Lib/test/test_pstats.py | 4 +- Lib/test/test_pty.py | 2 +- Lib/test/test_pwd.py | 4 +- Lib/test/test_pyclbr.py | 2 +- Lib/test/test_pydoc.py | 4 +- Lib/test/test_pyexpat.py | 2 +- Lib/test/test_queue.py | 4 +- Lib/test/test_quopri.py | 4 +- Lib/test/test_raise.py | 4 +- Lib/test/test_random.py | 8 +- Lib/test/test_range.py | 4 +- Lib/test/test_re.py | 2 +- Lib/test/test_reprlib.py | 2 +- Lib/test/test_resource.py | 8 +- Lib/test/test_rfc822.py | 4 +- Lib/test/test_richcmp.py | 10 +- Lib/test/test_robotparser.py | 8 +- Lib/test/test_runpy.py | 2 +- Lib/test/test_sax.py | 2 +- Lib/test/test_scope.py | 2 +- Lib/test/test_select.py | 14 +- Lib/test/test_set.py | 18 +- Lib/test/test_setcomps.py | 6 +- Lib/test/test_sgmllib.py | 6 +- Lib/test/test_shelve.py | 8 +- Lib/test/test_shlex.py | 4 +- Lib/test/test_shutil.py | 6 +- Lib/test/test_signal.py | 26 +- Lib/test/test_site.py | 2 +- Lib/test/test_slice.py | 4 +- Lib/test/test_smtplib.py | 14 +- Lib/test/test_socket.py | 18 +- Lib/test/test_socketserver.py | 12 +- Lib/test/test_sort.py | 8 +- Lib/test/test_sqlite.py | 2 +- Lib/test/test_ssl.py | 170 +++--- Lib/test/test_startfile.py | 4 +- Lib/test/test_strftime.py | 16 +- Lib/test/test_string.py | 4 +- Lib/test/test_stringprep.py | 4 +- Lib/test/test_strptime.py | 4 +- Lib/test/test_struct.py | 6 +- Lib/test/test_structmembers.py | 16 +- Lib/test/test_structseq.py | 4 +- Lib/test/test_subprocess.py | 20 +- Lib/test/test_sundry.py | 8 +- Lib/test/test_super.py | 4 +- Lib/test/test_support.py | 769 ---------------------------- Lib/test/test_symtable.py | 4 +- Lib/test/test_syntax.py | 6 +- Lib/test/test_sys.py | 4 +- Lib/test/test_syslog.py | 4 +- Lib/test/test_tarfile.py | 6 +- Lib/test/test_tcl.py | 4 +- Lib/test/test_telnetlib.py | 8 +- Lib/test/test_tempfile.py | 8 +- Lib/test/test_textwrap.py | 4 +- Lib/test/test_thread.py | 6 +- Lib/test/test_threaded_import.py | 2 +- Lib/test/test_threadedtempfile.py | 2 +- Lib/test/test_threading.py | 6 +- Lib/test/test_threading_local.py | 4 +- Lib/test/test_threadsignals.py | 2 +- Lib/test/test_time.py | 4 +- Lib/test/test_timeout.py | 8 +- Lib/test/test_tokenize.py | 16 +- Lib/test/test_trace.py | 4 +- Lib/test/test_traceback.py | 2 +- Lib/test/test_tuple.py | 4 +- Lib/test/test_typechecks.py | 4 +- Lib/test/test_types.py | 2 +- Lib/test/test_ucn.py | 4 +- Lib/test/test_unary.py | 2 +- Lib/test/test_unicode.py | 6 +- Lib/test/test_unicode_file.py | 4 +- Lib/test/test_unicodedata.py | 4 +- Lib/test/test_unittest.py | 4 +- Lib/test/test_univnewlines.py | 20 +- Lib/test/test_unpack.py | 4 +- Lib/test/test_unpack_ex.py | 4 +- Lib/test/test_urllib.py | 32 +- Lib/test/test_urllib2.py | 10 +- Lib/test/test_urllib2_localnet.py | 8 +- Lib/test/test_urllib2net.py | 10 +- Lib/test/test_urllibnet.py | 10 +- Lib/test/test_urlparse.py | 4 +- Lib/test/test_userdict.py | 4 +- Lib/test/test_userlist.py | 4 +- Lib/test/test_userstring.py | 4 +- Lib/test/test_uu.py | 12 +- Lib/test/test_uuid.py | 4 +- Lib/test/test_wait3.py | 2 +- Lib/test/test_wait4.py | 2 +- Lib/test/test_warnings.py | 50 +- Lib/test/test_wave.py | 2 +- Lib/test/test_weakref.py | 6 +- Lib/test/test_weakset.py | 4 +- Lib/test/test_whichdb.py | 8 +- Lib/test/test_winreg.py | 4 +- Lib/test/test_winsound.py | 6 +- Lib/test/test_with.py | 2 +- Lib/test/test_wsgiref.py | 4 +- Lib/test/test_xdrlib.py | 4 +- Lib/test/test_xml_etree.py | 4 +- Lib/test/test_xml_etree_c.py | 4 +- Lib/test/test_xmlrpc.py | 16 +- Lib/test/test_xmlrpc_net.py | 6 +- Lib/test/test_zipfile.py | 4 +- Lib/test/test_zipfile64.py | 8 +- Lib/test/test_zipimport.py | 16 +- Lib/test/test_zlib.py | 4 +- Lib/test/xmltests.py | 4 +- Misc/NEWS | 2 + 359 files changed, 2074 insertions(+), 2073 deletions(-) create mode 100644 Lib/test/support.py delete mode 100644 Lib/test/test_support.py diff --git a/Doc/library/test.rst b/Doc/library/test.rst index a6a3584..4c0af39 100644 --- a/Doc/library/test.rst +++ b/Doc/library/test.rst @@ -179,14 +179,14 @@ at the top-level directory where Python was built. On Windows, executing tests. -:mod:`test.test_support` --- Utility functions for tests +:mod:`test.support` --- Utility functions for tests ======================================================== -.. module:: test.test_support +.. module:: test.support :synopsis: Support for Python regression tests. -The :mod:`test.test_support` module provides support for Python's regression +The :mod:`test.support` module provides support for Python's regression tests. This module defines the following exceptions: @@ -236,7 +236,7 @@ The :mod:`test.test_support` module defines the following constants: Set to the path that a temporary file may be created at. Any temporary that is created should be closed and unlinked (removed). -The :mod:`test.test_support` module defines the following functions: +The :mod:`test.support` module defines the following functions: .. function:: forget(module_name) @@ -311,7 +311,7 @@ The :mod:`test.test_support` module defines the following functions: assert s.getvalue() == "hello" -The :mod:`test.test_support` module defines the following classes: +The :mod:`test.support` module defines the following classes: .. class:: TransientResource(exc[, **kwargs]) diff --git a/Lib/bsddb/test/test_associate.py b/Lib/bsddb/test/test_associate.py index 1c80a88..b9f250b 100644 --- a/Lib/bsddb/test/test_associate.py +++ b/Lib/bsddb/test/test_associate.py @@ -27,7 +27,7 @@ except ImportError: try: from bsddb3 import test_support except ImportError: - from test import test_support + from test import support as test_support #---------------------------------------------------------------------- diff --git a/Lib/bsddb/test/test_basics.py b/Lib/bsddb/test/test_basics.py index 6b99cc1..9c829bd 100644 --- a/Lib/bsddb/test/test_basics.py +++ b/Lib/bsddb/test/test_basics.py @@ -23,7 +23,7 @@ from bsddb.test.test_all import verbose try: from bsddb3 import test_support except ImportError: - from test import test_support + from test import support as test_support DASH = b'-' letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' diff --git a/Lib/bsddb/test/test_compare.py b/Lib/bsddb/test/test_compare.py index 2c9706a..e2562fb 100644 --- a/Lib/bsddb/test/test_compare.py +++ b/Lib/bsddb/test/test_compare.py @@ -19,7 +19,7 @@ except ImportError: try: from bsddb3 import test_support except ImportError: - from test import test_support + from test import support as test_support lexical_cmp = cmp diff --git a/Lib/bsddb/test/test_cursor_pget_bug.py b/Lib/bsddb/test/test_cursor_pget_bug.py index 887a69e..a06428ca 100644 --- a/Lib/bsddb/test/test_cursor_pget_bug.py +++ b/Lib/bsddb/test/test_cursor_pget_bug.py @@ -9,7 +9,7 @@ from bsddb import db try: from bsddb3 import test_support except ImportError: - from test import test_support + from test import support as test_support #---------------------------------------------------------------------- diff --git a/Lib/bsddb/test/test_dbobj.py b/Lib/bsddb/test/test_dbobj.py index f67af40..5f3170d 100644 --- a/Lib/bsddb/test/test_dbobj.py +++ b/Lib/bsddb/test/test_dbobj.py @@ -14,7 +14,7 @@ except ImportError: try: from bsddb3 import test_support except ImportError: - from test import test_support + from test import support as test_support #---------------------------------------------------------------------- diff --git a/Lib/bsddb/test/test_dbshelve.py b/Lib/bsddb/test/test_dbshelve.py index a597154..95f7ad1 100644 --- a/Lib/bsddb/test/test_dbshelve.py +++ b/Lib/bsddb/test/test_dbshelve.py @@ -12,7 +12,7 @@ from bsddb import db, dbshelve try: from bsddb3 import test_support except ImportError: - from test import test_support + from test import support as test_support from bsddb.test.test_all import verbose diff --git a/Lib/bsddb/test/test_dbtables.py b/Lib/bsddb/test/test_dbtables.py index f1328f0..061a731 100644 --- a/Lib/bsddb/test/test_dbtables.py +++ b/Lib/bsddb/test/test_dbtables.py @@ -37,7 +37,7 @@ except ImportError: try: from bsddb3 import test_support except ImportError: - from test import test_support + from test import support as test_support #---------------------------------------------------------------------- diff --git a/Lib/bsddb/test/test_env_close.py b/Lib/bsddb/test/test_env_close.py index 9f7c853..4809685 100644 --- a/Lib/bsddb/test/test_env_close.py +++ b/Lib/bsddb/test/test_env_close.py @@ -18,7 +18,7 @@ except ImportError: try: from bsddb3 import test_support except ImportError: - from test import test_support + from test import support as test_support from bsddb.test.test_all import verbose diff --git a/Lib/bsddb/test/test_join.py b/Lib/bsddb/test/test_join.py index 311835a..de674ee 100644 --- a/Lib/bsddb/test/test_join.py +++ b/Lib/bsddb/test/test_join.py @@ -21,7 +21,7 @@ from bsddb import db, dbshelve, StringKeys try: from bsddb3 import test_support except ImportError: - from test import test_support + from test import support as test_support #---------------------------------------------------------------------- diff --git a/Lib/bsddb/test/test_lock.py b/Lib/bsddb/test/test_lock.py index 1259d03..5baba69 100644 --- a/Lib/bsddb/test/test_lock.py +++ b/Lib/bsddb/test/test_lock.py @@ -26,7 +26,7 @@ except ImportError: try: from bsddb3 import test_support except ImportError: - from test import test_support + from test import support as test_support #---------------------------------------------------------------------- diff --git a/Lib/bsddb/test/test_misc.py b/Lib/bsddb/test/test_misc.py index 0d81288..03c08f4 100644 --- a/Lib/bsddb/test/test_misc.py +++ b/Lib/bsddb/test/test_misc.py @@ -17,7 +17,7 @@ except ImportError: try: from bsddb3 import test_support except ImportError: - from test import test_support + from test import support as test_support #---------------------------------------------------------------------- diff --git a/Lib/bsddb/test/test_pickle.py b/Lib/bsddb/test/test_pickle.py index f4c34ab..c1175e6 100644 --- a/Lib/bsddb/test/test_pickle.py +++ b/Lib/bsddb/test/test_pickle.py @@ -16,7 +16,7 @@ except ImportError as e: try: from bsddb3 import test_support except ImportError: - from test import test_support + from test import support as test_support #---------------------------------------------------------------------- diff --git a/Lib/bsddb/test/test_recno.py b/Lib/bsddb/test/test_recno.py index 6855d18..3bc2f2d 100644 --- a/Lib/bsddb/test/test_recno.py +++ b/Lib/bsddb/test/test_recno.py @@ -21,7 +21,7 @@ except ImportError: try: from bsddb3 import test_support except ImportError: - from test import test_support + from test import support as test_support letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' diff --git a/Lib/bsddb/test/test_sequence.py b/Lib/bsddb/test/test_sequence.py index 90be5f6..2e9c993 100644 --- a/Lib/bsddb/test/test_sequence.py +++ b/Lib/bsddb/test/test_sequence.py @@ -14,7 +14,7 @@ from bsddb.test.test_all import verbose try: from bsddb3 import test_support except ImportError: - from test import test_support + from test import support as test_support class DBSequenceTest(unittest.TestCase): diff --git a/Lib/bsddb/test/test_thread.py b/Lib/bsddb/test/test_thread.py index 51ed0f5..e39124e 100644 --- a/Lib/bsddb/test/test_thread.py +++ b/Lib/bsddb/test/test_thread.py @@ -36,7 +36,7 @@ except ImportError: try: from bsddb3 import test_support except ImportError: - from test import test_support + from test import support as test_support #---------------------------------------------------------------------- diff --git a/Lib/distutils/tests/test_core.py b/Lib/distutils/tests/test_core.py index 8e274dd..170d767 100644 --- a/Lib/distutils/tests/test_core.py +++ b/Lib/distutils/tests/test_core.py @@ -5,7 +5,7 @@ import distutils.core import os import shutil import sys -import test.test_support +import test.support import unittest @@ -39,13 +39,13 @@ class CoreTestCase(unittest.TestCase): self.cleanup_testfn() def cleanup_testfn(self): - path = test.test_support.TESTFN + path = test.support.TESTFN if os.path.isfile(path): os.remove(path) elif os.path.isdir(path): shutil.rmtree(path) - def write_setup(self, text, path=test.test_support.TESTFN): + def write_setup(self, text, path=test.support.TESTFN): open(path, "w").write(text) return path @@ -63,8 +63,8 @@ class CoreTestCase(unittest.TestCase): cwd = os.getcwd() # Create a directory and write the setup.py file there: - os.mkdir(test.test_support.TESTFN) - setup_py = os.path.join(test.test_support.TESTFN, "setup.py") + os.mkdir(test.support.TESTFN) + setup_py = os.path.join(test.support.TESTFN, "setup.py") distutils.core.run_setup( self.write_setup(setup_prints_cwd, path=setup_py)) diff --git a/Lib/distutils/tests/test_dist.py b/Lib/distutils/tests/test_dist.py index dd07735..f1b11c1 100644 --- a/Lib/distutils/tests/test_dist.py +++ b/Lib/distutils/tests/test_dist.py @@ -7,7 +7,7 @@ import io import sys import unittest -from test.test_support import TESTFN +from test.support import TESTFN class test_dist(distutils.cmd.Command): diff --git a/Lib/distutils/tests/test_sysconfig.py b/Lib/distutils/tests/test_sysconfig.py index aa1187e..c6ab9aa 100644 --- a/Lib/distutils/tests/test_sysconfig.py +++ b/Lib/distutils/tests/test_sysconfig.py @@ -4,7 +4,7 @@ from distutils import sysconfig import os import unittest -from test.test_support import TESTFN +from test.support import TESTFN class SysconfigTestCase(unittest.TestCase): diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py index 1ca41e9..9639d30 100644 --- a/Lib/email/test/test_email.py +++ b/Lib/email/test/test_email.py @@ -34,7 +34,7 @@ from email import iterators from email import base64mime from email import quoprimime -from test.test_support import findfile, run_unittest +from test.support import findfile, run_unittest from email.test import __file__ as landmark diff --git a/Lib/email/test/test_email_codecs.py b/Lib/email/test/test_email_codecs.py index 1c77347..a7bcb89 100644 --- a/Lib/email/test/test_email_codecs.py +++ b/Lib/email/test/test_email_codecs.py @@ -3,7 +3,7 @@ # email package unit tests for (optional) Asian codecs import unittest -from test.test_support import TestSkipped, run_unittest +from test.support import TestSkipped, run_unittest from email.test.test_email import TestEmailBase from email.Charset import Charset diff --git a/Lib/email/test/test_email_codecs_renamed.py b/Lib/email/test/test_email_codecs_renamed.py index d190de3..7122212 100644 --- a/Lib/email/test/test_email_codecs_renamed.py +++ b/Lib/email/test/test_email_codecs_renamed.py @@ -3,7 +3,7 @@ # email package unit tests for (optional) Asian codecs import unittest -from test.test_support import TestSkipped, run_unittest +from test.support import TestSkipped, run_unittest from email.test.test_email import TestEmailBase from email.charset import Charset diff --git a/Lib/email/test/test_email_torture.py b/Lib/email/test/test_email_torture.py index 67f106a..57233bf 100644 --- a/Lib/email/test/test_email_torture.py +++ b/Lib/email/test/test_email_torture.py @@ -13,7 +13,7 @@ from io import StringIO from types import ListType from email.test.test_email import TestEmailBase -from test.test_support import TestSkipped +from test.support import TestSkipped import email from email import __file__ as testfile @@ -128,7 +128,7 @@ def suite(): def test_main(): for testclass in _testclasses(): - test_support.run_unittest(testclass) + support.run_unittest(testclass) diff --git a/Lib/test/double_const.py b/Lib/test/double_const.py index 16c33a1..67852aa 100644 --- a/Lib/test/double_const.py +++ b/Lib/test/double_const.py @@ -1,4 +1,4 @@ -from test.test_support import TestFailed +from test.support import TestFailed # A test for SF bug 422177: manifest float constants varied way too much in # precision depending on whether Python was loading a module for the first diff --git a/Lib/test/list_tests.py b/Lib/test/list_tests.py index 4ffa668..6250908 100644 --- a/Lib/test/list_tests.py +++ b/Lib/test/list_tests.py @@ -5,7 +5,7 @@ Tests common to list and UserList.UserList import sys import os -from test import test_support, seq_tests +from test import support, seq_tests def CmpToKey(mycmp): 'Convert a cmp= function into a key= function' @@ -66,14 +66,14 @@ class CommonTest(seq_tests.CommonTest): d.append(d) d.append(400) try: - fo = open(test_support.TESTFN, "w") + fo = open(support.TESTFN, "w") fo.write(str(d)) fo.close() - fo = open(test_support.TESTFN, "r") + fo = open(support.TESTFN, "r") self.assertEqual(fo.read(), repr(d)) finally: fo.close() - os.remove(test_support.TESTFN) + os.remove(support.TESTFN) def test_set_subscript(self): a = self.type2test(range(20)) diff --git a/Lib/test/outstanding_bugs.py b/Lib/test/outstanding_bugs.py index 3f672fb..9e4784c 100644 --- a/Lib/test/outstanding_bugs.py +++ b/Lib/test/outstanding_bugs.py @@ -7,7 +7,7 @@ # import unittest -from test import test_support +from test import support # # One test case for outstanding bugs at the moment: @@ -22,7 +22,7 @@ class TextIOWrapperTest(unittest.TestCase): self.normalized = b"AAA\nBBB\nCCC\nDDD\nEEE\n".decode("ASCII") def tearDown(self): - test_support.unlink(test_support.TESTFN) + support.unlink(support.TESTFN) def test_issue1395_1(self): @@ -81,7 +81,7 @@ class TextIOWrapperTest(unittest.TestCase): def test_main(): - test_support.run_unittest( + support.run_unittest( TextIOWrapperTest) if __name__ == "__main__": diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py index 666b9c2..783d361 100644 --- a/Lib/test/pickletester.py +++ b/Lib/test/pickletester.py @@ -3,7 +3,7 @@ import pickle import pickletools import copyreg -from test.test_support import TestFailed, TESTFN, run_with_locale +from test.support import TestFailed, TESTFN, run_with_locale from pickle import bytes_types diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py index f87b8a8..41772c6 100755 --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -171,7 +171,7 @@ if sys.platform == 'darwin': newsoft = min(hard, max(soft, 1024*2048)) resource.setrlimit(resource.RLIMIT_STACK, (newsoft, hard)) -from test import test_support +from test import support RESOURCE_NAMES = ('audio', 'curses', 'largefile', 'network', 'bsddb', 'decimal', 'compiler', 'subprocess', 'urlfetch') @@ -209,7 +209,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False, values that would normally be set by flags on the command line. """ - test_support.record_original_stdout(sys.stdout) + support.record_original_stdout(sys.stdout) try: opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsSrf:lu:t:TD:NLR:wM:n', ['help', 'verbose', 'quiet', 'exclude', @@ -284,7 +284,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False, # stringobject.c filling slowly with random data warm_char_cache() elif o in ('-M', '--memlimit'): - test_support.set_memlimit(a) + support.set_memlimit(a) elif o in ('-u', '--use'): u = [x.lower() for x in a.split(',')] for r in u: @@ -390,8 +390,8 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False, tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix], trace=False, count=True) test_times = [] - test_support.verbose = verbose # Tell tests to be moderately quiet - test_support.use_resources = use_resources + support.verbose = verbose # Tell tests to be moderately quiet + support.use_resources = use_resources save_modules = sys.modules.keys() for test in tests: if not quiet: @@ -433,7 +433,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False, # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): - test_support.unload(module) + support.unload(module) # The lists won't be sorted if running with -r good.sort() @@ -479,7 +479,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False, print("Re-running test %r in verbose mode" % test) sys.stdout.flush() try: - test_support.verbose = True + support.verbose = True ok = runtest(test, generate, True, quiet, test_times, testdir, huntrleaks, debug) except KeyboardInterrupt: @@ -526,7 +526,6 @@ STDTESTS = [ ] NOTTESTS = { - 'test_support', 'test_future1', 'test_future2', } @@ -572,7 +571,7 @@ def runtest(test, generate, verbose, quiet, test_times, def runtest_inner(test, generate, verbose, quiet, test_times, testdir=None, huntrleaks=False, debug=False): - test_support.unload(test) + support.unload(test) if not testdir: testdir = findtestdir() if verbose: @@ -606,19 +605,19 @@ def runtest_inner(test, generate, verbose, quiet, test_times, test_times.append((test_time, test)) finally: sys.stdout = save_stdout - except test_support.ResourceDenied as msg: + except support.ResourceDenied as msg: if not quiet: print(test, "skipped --", msg) sys.stdout.flush() return -2 - except (ImportError, test_support.TestSkipped) as msg: + except (ImportError, support.TestSkipped) as msg: if not quiet: print(test, "skipped --", msg) sys.stdout.flush() return -1 except KeyboardInterrupt: raise - except test_support.TestFailed as msg: + except support.TestFailed as msg: print("test", test, "failed --", msg) sys.stdout.flush() return 0 @@ -652,7 +651,7 @@ def cleanup_test_droppings(testname, verbose): # since if a test leaves a file open, it cannot be deleted by name (while # there's nothing we can do about that here either, we can display the # name of the offending test, which is a real help). - for name in (test_support.TESTFN, + for name in (support.TESTFN, "db_home", ): if not os.path.exists(name): @@ -1206,10 +1205,10 @@ class _ExpectedSkips: if __name__ == '__main__': # Remove regrtest.py's own directory from the module search path. This # prevents relative imports from working, and relative imports will screw - # up the testing framework. E.g. if both test.test_support and - # test_support are imported, they will not contain the same globals, and + # up the testing framework. E.g. if both test.support and + # support are imported, they will not contain the same globals, and # much of the testing framework relies on the globals in the - # test.test_support module. + # test.support module. mydir = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0]))) i = pathlen = len(sys.path) while i >= 0: diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py index caafb31..60308d7 100644 --- a/Lib/test/string_tests.py +++ b/Lib/test/string_tests.py @@ -3,7 +3,7 @@ Common tests shared by test_str, test_unicode, test_userstring and test_string. """ import unittest, string, sys, struct -from test import test_support +from test import support from collections import UserList class Sequence: diff --git a/Lib/test/support.py b/Lib/test/support.py new file mode 100644 index 0000000..b8bc406 --- /dev/null +++ b/Lib/test/support.py @@ -0,0 +1,769 @@ +"""Supporting definitions for the Python regression tests.""" + +if __name__ != 'test.support': + raise ImportError('support must be imported from the test package') + +import contextlib +import errno +import socket +import sys +import os +import os.path +import shutil +import warnings +import unittest + +class Error(Exception): + """Base class for regression test exceptions.""" + +class TestFailed(Error): + """Test failed.""" + +class TestSkipped(Error): + """Test skipped. + + This can be raised to indicate that a test was deliberatly + skipped, but not because a feature wasn't available. For + example, if some resource can't be used, such as the network + appears to be unavailable, this should be raised instead of + TestFailed. + """ + +class ResourceDenied(TestSkipped): + """Test skipped because it requested a disallowed resource. + + This is raised when a test calls requires() for a resource that + has not be enabled. It is used to distinguish between expected + and unexpected skips. + """ + +def import_module(name, deprecated=False): + """Import the module to be tested, raising TestSkipped if it is not + available.""" + with catch_warning(record=False): + if deprecated: + warnings.filterwarnings("ignore", ".+ (module|package)", + DeprecationWarning) + try: + module = __import__(name, level=0) + except ImportError: + raise TestSkipped("No module named " + name) + else: + return module + +verbose = 1 # Flag set to 0 by regrtest.py +use_resources = None # Flag set to [] by regrtest.py +max_memuse = 0 # Disable bigmem tests (they will still be run with + # small sizes, to make sure they work.) + +# _original_stdout is meant to hold stdout at the time regrtest began. +# This may be "the real" stdout, or IDLE's emulation of stdout, or whatever. +# The point is to have some flavor of stdout the user can actually see. +_original_stdout = None +def record_original_stdout(stdout): + global _original_stdout + _original_stdout = stdout + +def get_original_stdout(): + return _original_stdout or sys.stdout + +def unload(name): + try: + del sys.modules[name] + except KeyError: + pass + +def unlink(filename): + try: + os.unlink(filename) + except OSError: + pass + +def rmtree(path): + try: + shutil.rmtree(path) + except OSError as e: + # Unix returns ENOENT, Windows returns ESRCH. + if e.errno not in (errno.ENOENT, errno.ESRCH): + raise + +def forget(modname): + '''"Forget" a module was ever imported by removing it from sys.modules and + deleting any .pyc and .pyo files.''' + unload(modname) + for dirname in sys.path: + unlink(os.path.join(dirname, modname + '.pyc')) + # Deleting the .pyo file cannot be within the 'try' for the .pyc since + # the chance exists that there is no .pyc (and thus the 'try' statement + # is exited) but there is a .pyo file. + unlink(os.path.join(dirname, modname + '.pyo')) + +def is_resource_enabled(resource): + """Test whether a resource is enabled. Known resources are set by + regrtest.py.""" + return use_resources is not None and resource in use_resources + +def requires(resource, msg=None): + """Raise ResourceDenied if the specified resource is not available. + + If the caller's module is __main__ then automatically return True. The + possibility of False being returned occurs when regrtest.py is executing.""" + # see if the caller's module is __main__ - if so, treat as if + # the resource was set + if sys._getframe().f_back.f_globals.get("__name__") == "__main__": + return + if not is_resource_enabled(resource): + if msg is None: + msg = "Use of the `%s' resource not enabled" % resource + raise ResourceDenied(msg) + +HOST = 'localhost' + +def find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM): + """Returns an unused port that should be suitable for binding. This is + achieved by creating a temporary socket with the same family and type as + the 'sock' parameter (default is AF_INET, SOCK_STREAM), and binding it to + the specified host address (defaults to 0.0.0.0) with the port set to 0, + eliciting an unused ephemeral port from the OS. The temporary socket is + then closed and deleted, and the ephemeral port is returned. + + Either this method or bind_port() should be used for any tests where a + server socket needs to be bound to a particular port for the duration of + the test. Which one to use depends on whether the calling code is creating + a python socket, or if an unused port needs to be provided in a constructor + or passed to an external program (i.e. the -accept argument to openssl's + s_server mode). Always prefer bind_port() over find_unused_port() where + possible. Hard coded ports should *NEVER* be used. As soon as a server + socket is bound to a hard coded port, the ability to run multiple instances + of the test simultaneously on the same host is compromised, which makes the + test a ticking time bomb in a buildbot environment. On Unix buildbots, this + may simply manifest as a failed test, which can be recovered from without + intervention in most cases, but on Windows, the entire python process can + completely and utterly wedge, requiring someone to log in to the buildbot + and manually kill the affected process. + + (This is easy to reproduce on Windows, unfortunately, and can be traced to + the SO_REUSEADDR socket option having different semantics on Windows versus + Unix/Linux. On Unix, you can't have two AF_INET SOCK_STREAM sockets bind, + listen and then accept connections on identical host/ports. An EADDRINUSE + socket.error will be raised at some point (depending on the platform and + the order bind and listen were called on each socket). + + However, on Windows, if SO_REUSEADDR is set on the sockets, no EADDRINUSE + will ever be raised when attempting to bind two identical host/ports. When + accept() is called on each socket, the second caller's process will steal + the port from the first caller, leaving them both in an awkwardly wedged + state where they'll no longer respond to any signals or graceful kills, and + must be forcibly killed via OpenProcess()/TerminateProcess(). + + The solution on Windows is to use the SO_EXCLUSIVEADDRUSE socket option + instead of SO_REUSEADDR, which effectively affords the same semantics as + SO_REUSEADDR on Unix. Given the propensity of Unix developers in the Open + Source world compared to Windows ones, this is a common mistake. A quick + look over OpenSSL's 0.9.8g source shows that they use SO_REUSEADDR when + openssl.exe is called with the 's_server' option, for example. See + http://bugs.python.org/issue2550 for more info. The following site also + has a very thorough description about the implications of both REUSEADDR + and EXCLUSIVEADDRUSE on Windows: + http://msdn2.microsoft.com/en-us/library/ms740621(VS.85).aspx) + + XXX: although this approach is a vast improvement on previous attempts to + elicit unused ports, it rests heavily on the assumption that the ephemeral + port returned to us by the OS won't immediately be dished back out to some + other process when we close and delete our temporary socket but before our + calling code has a chance to bind the returned port. We can deal with this + issue if/when we come across it. + """ + + tempsock = socket.socket(family, socktype) + port = bind_port(tempsock) + tempsock.close() + del tempsock + return port + +def bind_port(sock, host=HOST): + """Bind the socket to a free port and return the port number. Relies on + ephemeral ports in order to ensure we are using an unbound port. This is + important as many tests may be running simultaneously, especially in a + buildbot environment. This method raises an exception if the sock.family + is AF_INET and sock.type is SOCK_STREAM, *and* the socket has SO_REUSEADDR + or SO_REUSEPORT set on it. Tests should *never* set these socket options + for TCP/IP sockets. The only case for setting these options is testing + multicasting via multiple UDP sockets. + + Additionally, if the SO_EXCLUSIVEADDRUSE socket option is available (i.e. + on Windows), it will be set on the socket. This will prevent anyone else + from bind()'ing to our host/port for the duration of the test. + """ + + if sock.family == socket.AF_INET and sock.type == socket.SOCK_STREAM: + if hasattr(socket, 'SO_REUSEADDR'): + if sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR) == 1: + raise TestFailed("tests should never set the SO_REUSEADDR " \ + "socket option on TCP/IP sockets!") + if hasattr(socket, 'SO_REUSEPORT'): + if sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT) == 1: + raise TestFailed("tests should never set the SO_REUSEPORT " \ + "socket option on TCP/IP sockets!") + if hasattr(socket, 'SO_EXCLUSIVEADDRUSE'): + sock.setsockopt(socket.SOL_SOCKET, socket.SO_EXCLUSIVEADDRUSE, 1) + + sock.bind((host, 0)) + port = sock.getsockname()[1] + return port + +FUZZ = 1e-6 + +def fcmp(x, y): # fuzzy comparison function + if isinstance(x, float) or isinstance(y, float): + try: + fuzz = (abs(x) + abs(y)) * FUZZ + if abs(x-y) <= fuzz: + return 0 + except: + pass + elif type(x) == type(y) and isinstance(x, (tuple, list)): + for i in range(min(len(x), len(y))): + outcome = fcmp(x[i], y[i]) + if outcome != 0: + return outcome + return (len(x) > len(y)) - (len(x) < len(y)) + return (x > y) - (x < y) + +try: + str + have_unicode = True +except NameError: + have_unicode = False + +is_jython = sys.platform.startswith('java') + +# Filename used for testing +if os.name == 'java': + # Jython disallows @ in module names + TESTFN = '$test' +else: + TESTFN = '@test' + + # Assuming sys.getfilesystemencoding()!=sys.getdefaultencoding() + # TESTFN_UNICODE is a filename that can be encoded using the + # file system encoding, but *not* with the default (ascii) encoding + TESTFN_UNICODE = "@test-\xe0\xf2" + TESTFN_ENCODING = sys.getfilesystemencoding() + # TESTFN_UNICODE_UNENCODEABLE is a filename that should *not* be + # able to be encoded by *either* the default or filesystem encoding. + # This test really only makes sense on Windows NT platforms + # which have special Unicode support in posixmodule. + if (not hasattr(sys, "getwindowsversion") or + sys.getwindowsversion()[3] < 2): # 0=win32s or 1=9x/ME + TESTFN_UNICODE_UNENCODEABLE = None + else: + # Japanese characters (I think - from bug 846133) + TESTFN_UNICODE_UNENCODEABLE = "@test-\u5171\u6709\u3055\u308c\u308b" + try: + # XXX - Note - should be using TESTFN_ENCODING here - but for + # Windows, "mbcs" currently always operates as if in + # errors=ignore' mode - hence we get '?' characters rather than + # the exception. 'Latin1' operates as we expect - ie, fails. + # See [ 850997 ] mbcs encoding ignores errors + TESTFN_UNICODE_UNENCODEABLE.encode("Latin1") + except UnicodeEncodeError: + pass + else: + print('WARNING: The filename %r CAN be encoded by the filesystem. ' + 'Unicode filename tests may not be effective' + % TESTFN_UNICODE_UNENCODEABLE) + +# Make sure we can write to TESTFN, try in /tmp if we can't +fp = None +try: + fp = open(TESTFN, 'w+') +except IOError: + TMP_TESTFN = os.path.join('/tmp', TESTFN) + try: + fp = open(TMP_TESTFN, 'w+') + TESTFN = TMP_TESTFN + del TMP_TESTFN + except IOError: + print(('WARNING: tests will fail, unable to write to: %s or %s' % + (TESTFN, TMP_TESTFN))) +if fp is not None: + fp.close() + unlink(TESTFN) +del fp + +def findfile(file, here=__file__): + """Try to find a file on sys.path and the working directory. If it is not + found the argument passed to the function is returned (this does not + necessarily signal failure; could still be the legitimate path).""" + if os.path.isabs(file): + return file + path = sys.path + path = [os.path.dirname(here)] + path + for dn in path: + fn = os.path.join(dn, file) + if os.path.exists(fn): return fn + return file + +def verify(condition, reason='test failed'): + """Verify that condition is true. If not, raise TestFailed. + + The optional argument reason can be given to provide + a better error text. + """ + + if not condition: + raise TestFailed(reason) + +def vereq(a, b): + """Raise TestFailed if a == b is false. + + This is better than verify(a == b) because, in case of failure, the + error message incorporates repr(a) and repr(b) so you can see the + inputs. + + Note that "not (a == b)" isn't necessarily the same as "a != b"; the + former is tested. + """ + + if not (a == b): + raise TestFailed("%r == %r" % (a, b)) + +def sortdict(dict): + "Like repr(dict), but in sorted order." + items = sorted(dict.items()) + reprpairs = ["%r: %r" % pair for pair in items] + withcommas = ", ".join(reprpairs) + return "{%s}" % withcommas + +def check_syntax_error(testcase, statement): + try: + compile(statement, '', 'exec') + except SyntaxError: + pass + else: + testcase.fail('Missing SyntaxError: "%s"' % statement) + +def open_urlresource(url, *args, **kw): + import urllib, urlparse + + requires('urlfetch') + filename = urlparse.urlparse(url)[2].split('/')[-1] # '/': it's URL! + + for path in [os.path.curdir, os.path.pardir]: + fn = os.path.join(path, filename) + if os.path.exists(fn): + return open(fn, *args, **kw) + + print('\tfetching %s ...' % url, file=get_original_stdout()) + fn, _ = urllib.urlretrieve(url, filename) + return open(fn, *args, **kw) + + +class WarningMessage(object): + "Holds the result of the latest showwarning() call" + def __init__(self): + self.message = None + self.category = None + self.filename = None + self.lineno = None + + def _showwarning(self, message, category, filename, lineno, file=None, + line=None): + self.message = message + self.category = category + self.filename = filename + self.lineno = lineno + self.line = line + + def reset(self): + self._showwarning(*((None,)*6)) + + def __str__(self): + return ("{message : %r, category : %r, filename : %r, lineno : %s, " + "line : %r}" % (self.message, + self.category.__name__ if self.category else None, + self.filename, self.lineno, self.line)) + + +@contextlib.contextmanager +def catch_warning(module=warnings, record=True): + """ + Guard the warnings filter from being permanently changed and record the + data of the last warning that has been issued. + + Use like this: + + with catch_warning() as w: + warnings.warn("foo") + assert str(w.message) == "foo" + """ + original_filters = module.filters[:] + original_showwarning = module.showwarning + if record: + warning_obj = WarningMessage() + module.showwarning = warning_obj._showwarning + try: + yield warning_obj if record else None + finally: + module.showwarning = original_showwarning + module.filters = original_filters + + +class CleanImport(object): + """Context manager to force import to return a new module reference. + + This is useful for testing module-level behaviours, such as + the emission of a DepreciationWarning on import. + + Use like this: + + with CleanImport("foo"): + __import__("foo") # new reference + """ + + def __init__(self, *module_names): + self.original_modules = sys.modules.copy() + for module_name in module_names: + if module_name in sys.modules: + module = sys.modules[module_name] + # It is possible that module_name is just an alias for + # another module (e.g. stub for modules renamed in 3.x). + # In that case, we also need delete the real module to clear + # the import cache. + if module.__name__ != module_name: + del sys.modules[module.__name__] + del sys.modules[module_name] + + def __enter__(self): + return self + + def __exit__(self, *ignore_exc): + sys.modules.update(self.original_modules) + + +class EnvironmentVarGuard(object): + + """Class to help protect the environment variable properly. Can be used as + a context manager.""" + + def __init__(self): + self._environ = os.environ + self._unset = set() + self._reset = dict() + + def set(self, envvar, value): + if envvar not in self._environ: + self._unset.add(envvar) + else: + self._reset[envvar] = self._environ[envvar] + self._environ[envvar] = value + + def unset(self, envvar): + if envvar in self._environ: + self._reset[envvar] = self._environ[envvar] + del self._environ[envvar] + + def __enter__(self): + return self + + def __exit__(self, *ignore_exc): + for envvar, value in self._reset.items(): + self._environ[envvar] = value + for unset in self._unset: + del self._environ[unset] + +class TransientResource(object): + + """Raise ResourceDenied if an exception is raised while the context manager + is in effect that matches the specified exception and attributes.""" + + def __init__(self, exc, **kwargs): + self.exc = exc + self.attrs = kwargs + + def __enter__(self): + return self + + def __exit__(self, type_=None, value=None, traceback=None): + """If type_ is a subclass of self.exc and value has attributes matching + self.attrs, raise ResourceDenied. Otherwise let the exception + propagate (if any).""" + if type_ is not None and issubclass(self.exc, type_): + for attr, attr_value in self.attrs.items(): + if not hasattr(value, attr): + break + if getattr(value, attr) != attr_value: + break + else: + raise ResourceDenied("an optional resource is not available") + + +def transient_internet(): + """Return a context manager that raises ResourceDenied when various issues + with the Internet connection manifest themselves as exceptions.""" + time_out = TransientResource(IOError, errno=errno.ETIMEDOUT) + socket_peer_reset = TransientResource(socket.error, errno=errno.ECONNRESET) + ioerror_peer_reset = TransientResource(IOError, errno=errno.ECONNRESET) + return contextlib.nested(time_out, socket_peer_reset, ioerror_peer_reset) + + +@contextlib.contextmanager +def captured_output(stream_name): + """Run the 'with' statement body using a StringIO object in place of a + specific attribute on the sys module. + Example use (with 'stream_name=stdout'):: + + with captured_stdout() as s: + print("hello") + assert s.getvalue() == "hello" + """ + import io + orig_stdout = getattr(sys, stream_name) + setattr(sys, stream_name, io.StringIO()) + try: + yield getattr(sys, stream_name) + finally: + setattr(sys, stream_name, orig_stdout) + +def captured_stdout(): + return captured_output("stdout") + + +#======================================================================= +# Decorator for running a function in a different locale, correctly resetting +# it afterwards. + +def run_with_locale(catstr, *locales): + def decorator(func): + def inner(*args, **kwds): + try: + import locale + category = getattr(locale, catstr) + orig_locale = locale.setlocale(category) + except AttributeError: + # if the test author gives us an invalid category string + raise + except: + # cannot retrieve original locale, so do nothing + locale = orig_locale = None + else: + for loc in locales: + try: + locale.setlocale(category, loc) + break + except: + pass + + # now run the function, resetting the locale on exceptions + try: + return func(*args, **kwds) + finally: + if locale and orig_locale: + locale.setlocale(category, orig_locale) + inner.__name__ = func.__name__ + inner.__doc__ = func.__doc__ + return inner + return decorator + +#======================================================================= +# Big-memory-test support. Separate from 'resources' because memory use +# should be configurable. + +# Some handy shorthands. Note that these are used for byte-limits as well +# as size-limits, in the various bigmem tests +_1M = 1024*1024 +_1G = 1024 * _1M +_2G = 2 * _1G + +MAX_Py_ssize_t = sys.maxsize + +def set_memlimit(limit): + import re + global max_memuse + sizes = { + 'k': 1024, + 'm': _1M, + 'g': _1G, + 't': 1024*_1G, + } + m = re.match(r'(\d+(\.\d+)?) (K|M|G|T)b?$', limit, + re.IGNORECASE | re.VERBOSE) + if m is None: + raise ValueError('Invalid memory limit %r' % (limit,)) + memlimit = int(float(m.group(1)) * sizes[m.group(3).lower()]) + if memlimit > MAX_Py_ssize_t: + memlimit = MAX_Py_ssize_t + if memlimit < _2G - 1: + raise ValueError('Memory limit %r too low to be useful' % (limit,)) + max_memuse = memlimit + +def bigmemtest(minsize, memuse, overhead=5*_1M): + """Decorator for bigmem tests. + + 'minsize' is the minimum useful size for the test (in arbitrary, + test-interpreted units.) 'memuse' is the number of 'bytes per size' for + the test, or a good estimate of it. 'overhead' specifies fixed overhead, + independent of the testsize, and defaults to 5Mb. + + The decorator tries to guess a good value for 'size' and passes it to + the decorated test function. If minsize * memuse is more than the + allowed memory use (as defined by max_memuse), the test is skipped. + Otherwise, minsize is adjusted upward to use up to max_memuse. + """ + def decorator(f): + def wrapper(self): + if not max_memuse: + # If max_memuse is 0 (the default), + # we still want to run the tests with size set to a few kb, + # to make sure they work. We still want to avoid using + # too much memory, though, but we do that noisily. + maxsize = 5147 + self.failIf(maxsize * memuse + overhead > 20 * _1M) + else: + maxsize = int((max_memuse - overhead) / memuse) + if maxsize < minsize: + # Really ought to print 'test skipped' or something + if verbose: + sys.stderr.write("Skipping %s because of memory " + "constraint\n" % (f.__name__,)) + return + # Try to keep some breathing room in memory use + maxsize = max(maxsize - 50 * _1M, minsize) + return f(self, maxsize) + wrapper.minsize = minsize + wrapper.memuse = memuse + wrapper.overhead = overhead + return wrapper + return decorator + +def bigaddrspacetest(f): + """Decorator for tests that fill the address space.""" + def wrapper(self): + if max_memuse < MAX_Py_ssize_t: + if verbose: + sys.stderr.write("Skipping %s because of memory " + "constraint\n" % (f.__name__,)) + else: + return f(self) + return wrapper + +#======================================================================= +# unittest integration. + +class BasicTestRunner: + def run(self, test): + result = unittest.TestResult() + test(result) + return result + + +def _run_suite(suite): + """Run tests from a unittest.TestSuite-derived class.""" + if verbose: + runner = unittest.TextTestRunner(sys.stdout, verbosity=2) + else: + runner = BasicTestRunner() + + result = runner.run(suite) + if not result.wasSuccessful(): + if len(result.errors) == 1 and not result.failures: + err = result.errors[0][1] + elif len(result.failures) == 1 and not result.errors: + err = result.failures[0][1] + else: + err = "errors occurred; run in verbose mode for details" + raise TestFailed(err) + + +def run_unittest(*classes): + """Run tests from unittest.TestCase-derived classes.""" + valid_types = (unittest.TestSuite, unittest.TestCase) + suite = unittest.TestSuite() + for cls in classes: + if isinstance(cls, str): + if cls in sys.modules: + suite.addTest(unittest.findTestCases(sys.modules[cls])) + else: + raise ValueError("str arguments must be keys in sys.modules") + elif isinstance(cls, valid_types): + suite.addTest(cls) + else: + suite.addTest(unittest.makeSuite(cls)) + _run_suite(suite) + + +#======================================================================= +# doctest driver. + +def run_doctest(module, verbosity=None): + """Run doctest on the given module. Return (#failures, #tests). + + If optional argument verbosity is not specified (or is None), pass + support's belief about verbosity on to doctest. Else doctest's + usual behavior is used (it searches sys.argv for -v). + """ + + import doctest + + if verbosity is None: + verbosity = verbose + else: + verbosity = None + + # Direct doctest output (normally just errors) to real stdout; doctest + # output shouldn't be compared by regrtest. + save_stdout = sys.stdout + sys.stdout = get_original_stdout() + try: + f, t = doctest.testmod(module, verbose=verbosity) + if f: + raise TestFailed("%d of %d doctests failed" % (f, t)) + finally: + sys.stdout = save_stdout + if verbose: + print('doctest (%s) ... %d tests with zero failures' % + (module.__name__, t)) + return f, t + +#======================================================================= +# Threading support to prevent reporting refleaks when running regrtest.py -R + +def threading_setup(): + import threading + return len(threading._active), len(threading._limbo) + +def threading_cleanup(num_active, num_limbo): + import threading + import time + + _MAX_COUNT = 10 + count = 0 + while len(threading._active) != num_active and count < _MAX_COUNT: + count += 1 + time.sleep(0.1) + + count = 0 + while len(threading._limbo) != num_limbo and count < _MAX_COUNT: + count += 1 + time.sleep(0.1) + +def reap_children(): + """Use this function at the end of test_main() whenever sub-processes + are started. This will help ensure that no extra children (zombies) + stick around to hog resources and create problems when looking + for refleaks. + """ + + # Reap all our dead child processes so we don't leave zombies around. + # These hog resources and might be causing some of the buildbots to die. + if hasattr(os, 'waitpid'): + any_process = -1 + while True: + try: + # This will raise an exception on Windows. That's ok. + pid, status = os.waitpid(any_process, os.WNOHANG) + if pid == 0: + break + except: + break diff --git a/Lib/test/test_SimpleHTTPServer.py b/Lib/test/test_SimpleHTTPServer.py index 9d3ad16..d285f27 100644 --- a/Lib/test/test_SimpleHTTPServer.py +++ b/Lib/test/test_SimpleHTTPServer.py @@ -5,7 +5,7 @@ We don't want to require the 'network' resource. import os, unittest from SimpleHTTPServer import SimpleHTTPRequestHandler -from test import test_support +from test import support class SocketlessRequestHandler (SimpleHTTPRequestHandler): @@ -35,7 +35,7 @@ class SimpleHTTPRequestHandlerTestCase(unittest.TestCase): def test_main(): - test_support.run_unittest(SimpleHTTPRequestHandlerTestCase) + support.run_unittest(SimpleHTTPRequestHandlerTestCase) if __name__ == "__main__": test_main() diff --git a/Lib/test/test___all__.py b/Lib/test/test___all__.py index 9d0487d..c58aead 100644 --- a/Lib/test/test___all__.py +++ b/Lib/test/test___all__.py @@ -1,5 +1,5 @@ import unittest -from test.test_support import run_unittest, catch_warning +from test.support import run_unittest, catch_warning import sys import warnings diff --git a/Lib/test/test___future__.py b/Lib/test/test___future__.py index 9504155..77006e1 100644 --- a/Lib/test/test___future__.py +++ b/Lib/test/test___future__.py @@ -1,6 +1,6 @@ #! /usr/bin/env python import unittest -from test import test_support +from test import support import __future__ GOOD_SERIALS = ("alpha", "beta", "candidate", "final") @@ -57,7 +57,7 @@ class FutureTest(unittest.TestCase): ".compiler_flag isn't int") def test_main(): - test_support.run_unittest(FutureTest) + support.run_unittest(FutureTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test__locale.py b/Lib/test/test__locale.py index aed273d..9dec027 100644 --- a/Lib/test/test__locale.py +++ b/Lib/test/test__locale.py @@ -1,4 +1,4 @@ -from test.test_support import verbose, TestSkipped, run_unittest +from test.support import verbose, TestSkipped, run_unittest from _locale import (setlocale, LC_ALL, LC_CTYPE, LC_NUMERIC, RADIXCHAR, THOUSEP, nl_langinfo, localeconv, Error) import unittest diff --git a/Lib/test/test_abc.py b/Lib/test/test_abc.py index d631c3e..a4cefc5 100644 --- a/Lib/test/test_abc.py +++ b/Lib/test/test_abc.py @@ -4,7 +4,7 @@ """Unit tests for abc.py.""" import unittest -from test import test_support +from test import support import abc from inspect import isabstract @@ -170,7 +170,7 @@ class TestABC(unittest.TestCase): def test_main(): - test_support.run_unittest(TestABC) + support.run_unittest(TestABC) if __name__ == "__main__": diff --git a/Lib/test/test_abstract_numbers.py b/Lib/test/test_abstract_numbers.py index 244f87a..e20f2d4 100644 --- a/Lib/test/test_abstract_numbers.py +++ b/Lib/test/test_abstract_numbers.py @@ -5,7 +5,7 @@ import operator import unittest from numbers import Complex, Real, Rational, Integral from numbers import Number -from test import test_support +from test import support class TestNumbers(unittest.TestCase): def test_int(self): @@ -40,7 +40,7 @@ class TestNumbers(unittest.TestCase): self.assertRaises(TypeError, int, c1) def test_main(): - test_support.run_unittest(TestNumbers) + support.run_unittest(TestNumbers) if __name__ == "__main__": diff --git a/Lib/test/test_anydbm.py b/Lib/test/test_anydbm.py index 9399d71..ace9dd2 100644 --- a/Lib/test/test_anydbm.py +++ b/Lib/test/test_anydbm.py @@ -7,9 +7,9 @@ import os import unittest import anydbm import glob -from test import test_support +from test import support -_fname = test_support.TESTFN +_fname = support.TESTFN _all_modules = [] @@ -121,7 +121,7 @@ class AnyDBMTestCase(unittest.TestCase): def test_main(): try: for module in dbm_iterator(): - test_support.run_unittest(AnyDBMTestCase) + support.run_unittest(AnyDBMTestCase) finally: delete_files() diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py index 70fac66..66ce2ad 100755 --- a/Lib/test/test_array.py +++ b/Lib/test/test_array.py @@ -4,7 +4,7 @@ """ import unittest -from test import test_support +from test import support from weakref import proxy import array, io, math from pickle import loads, dumps @@ -162,13 +162,13 @@ class BaseTest(unittest.TestCase): def test_tofromfile(self): a = array.array(self.typecode, 2*self.example) self.assertRaises(TypeError, a.tofile) - test_support.unlink(test_support.TESTFN) - f = open(test_support.TESTFN, 'wb') + support.unlink(support.TESTFN) + f = open(support.TESTFN, 'wb') try: a.tofile(f) f.close() b = array.array(self.typecode) - f = open(test_support.TESTFN, 'rb') + f = open(support.TESTFN, 'rb') self.assertRaises(TypeError, b.fromfile) b.fromfile(f, len(self.example)) self.assertEqual(b, array.array(self.typecode, self.example)) @@ -180,7 +180,7 @@ class BaseTest(unittest.TestCase): finally: if not f.closed: f.close() - test_support.unlink(test_support.TESTFN) + support.unlink(support.TESTFN) def test_tofromlist(self): a = array.array(self.typecode, 2*self.example) @@ -967,14 +967,14 @@ tests.append(DoubleTest) def test_main(verbose=None): import sys - test_support.run_unittest(*tests) + support.run_unittest(*tests) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in range(len(counts)): - test_support.run_unittest(*tests) + support.run_unittest(*tests) gc.collect() counts[i] = sys.gettotalrefcount() print(counts) diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py index f4fbc94..4c74cf7 100644 --- a/Lib/test/test_ast.py +++ b/Lib/test/test_ast.py @@ -1,5 +1,5 @@ import sys, unittest -from test import test_support +from test import support import _ast def to_tuple(t): @@ -176,7 +176,7 @@ class AST_Tests(unittest.TestCase): self.assertEquals(to_tuple(ast2), to_tuple(ast)) def test_main(): - test_support.run_unittest(AST_Tests) + support.run_unittest(AST_Tests) def main(): if __name__ != '__main__': diff --git a/Lib/test/test_asynchat.py b/Lib/test/test_asynchat.py index d24e8cc..4d49f58 100644 --- a/Lib/test/test_asynchat.py +++ b/Lib/test/test_asynchat.py @@ -4,9 +4,9 @@ import thread # If this fails, we can't test this module import asyncore, asynchat, socket, threading, time import unittest import sys -from test import test_support +from test import support -HOST = test_support.HOST +HOST = support.HOST SERVER_QUIT = b'QUIT\n' class echo_server(threading.Thread): @@ -18,7 +18,7 @@ class echo_server(threading.Thread): threading.Thread.__init__(self) self.event = event self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.port = test_support.bind_port(self.sock) + self.port = support.bind_port(self.sock) def run(self): self.sock.listen(1) @@ -248,7 +248,7 @@ class TestFifo(unittest.TestCase): def test_main(verbose=None): - test_support.run_unittest(TestAsynchat, TestAsynchat_WithPoll, + support.run_unittest(TestAsynchat, TestAsynchat_WithPoll, TestHelperFunctions, TestFifo) if __name__ == "__main__": diff --git a/Lib/test/test_asyncore.py b/Lib/test/test_asyncore.py index 09401bd..eb52687 100644 --- a/Lib/test/test_asyncore.py +++ b/Lib/test/test_asyncore.py @@ -7,12 +7,12 @@ import threading import sys import time -from test import test_support -from test.test_support import TESTFN, run_unittest, unlink +from test import support +from test.support import TESTFN, run_unittest, unlink from io import BytesIO from io import StringIO -HOST = test_support.HOST +HOST = support.HOST class dummysocket: def __init__(self): @@ -334,7 +334,7 @@ class DispatcherWithSendTests(unittest.TestCase): self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(3) - self.port = test_support.bind_port(self.sock) + self.port = support.bind_port(self.sock) cap = BytesIO() args = (self.evt, cap, self.sock) diff --git a/Lib/test/test_atexit.py b/Lib/test/test_atexit.py index 76a5036..6856042 100644 --- a/Lib/test/test_atexit.py +++ b/Lib/test/test_atexit.py @@ -2,7 +2,7 @@ import sys import unittest import io import atexit -from test import test_support +from test import support ### helpers def h1(): @@ -109,7 +109,7 @@ class TestCase(unittest.TestCase): def test_main(): - test_support.run_unittest(TestCase) + support.run_unittest(TestCase) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_audioop.py b/Lib/test/test_audioop.py index ab8be02..ae796ba 100644 --- a/Lib/test/test_audioop.py +++ b/Lib/test/test_audioop.py @@ -1,6 +1,6 @@ # Test audioop. import audioop -from test.test_support import verbose +from test.support import verbose def gendata1(): return b'\0\1\2' diff --git a/Lib/test/test_augassign.py b/Lib/test/test_augassign.py index 0309d6e..e03b4d4 100644 --- a/Lib/test/test_augassign.py +++ b/Lib/test/test_augassign.py @@ -1,6 +1,6 @@ # Augmented assignment test. -from test.test_support import run_unittest +from test.support import run_unittest import unittest diff --git a/Lib/test/test_base64.py b/Lib/test/test_base64.py index c50652c..e899016 100644 --- a/Lib/test/test_base64.py +++ b/Lib/test/test_base64.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support import base64 import binascii @@ -209,7 +209,7 @@ class BaseXYTestCase(unittest.TestCase): def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_bigaddrspace.py b/Lib/test/test_bigaddrspace.py index 8c215fe..3aedc4cf 100644 --- a/Lib/test/test_bigaddrspace.py +++ b/Lib/test/test_bigaddrspace.py @@ -1,5 +1,5 @@ -from test import test_support -from test.test_support import bigaddrspacetest, MAX_Py_ssize_t +from test import support +from test.support import bigaddrspacetest, MAX_Py_ssize_t import unittest import operator @@ -38,9 +38,9 @@ class StrTest(unittest.TestCase): def test_main(): - test_support.run_unittest(StrTest) + support.run_unittest(StrTest) if __name__ == '__main__': if len(sys.argv) > 1: - test_support.set_memlimit(sys.argv[1]) + support.set_memlimit(sys.argv[1]) test_main() diff --git a/Lib/test/test_bigmem.py b/Lib/test/test_bigmem.py index 27e1ecf..30e1bdb 100644 --- a/Lib/test/test_bigmem.py +++ b/Lib/test/test_bigmem.py @@ -1,5 +1,5 @@ -from test import test_support -from test.test_support import bigmemtest, _1G, _2G +from test import support +from test.support import bigmemtest, _1G, _2G import unittest import operator @@ -957,9 +957,9 @@ class ListTest(unittest.TestCase): self.assertEquals(l[-10:], [5] * 10) def test_main(): - test_support.run_unittest(StrTest, TupleTest, ListTest) + support.run_unittest(StrTest, TupleTest, ListTest) if __name__ == '__main__': if len(sys.argv) > 1: - test_support.set_memlimit(sys.argv[1]) + support.set_memlimit(sys.argv[1]) test_main() diff --git a/Lib/test/test_binascii.py b/Lib/test/test_binascii.py index fb9a666..76a76b2 100755 --- a/Lib/test/test_binascii.py +++ b/Lib/test/test_binascii.py @@ -1,6 +1,6 @@ """Test the binascii C module.""" -from test import test_support +from test import support import unittest import binascii @@ -169,7 +169,7 @@ class BinASCIITest(unittest.TestCase): binascii.crc_hqx('', 0) def test_main(): - test_support.run_unittest(BinASCIITest) + support.run_unittest(BinASCIITest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_binhex.py b/Lib/test/test_binhex.py index 61c24c9..06fd98a 100755 --- a/Lib/test/test_binhex.py +++ b/Lib/test/test_binhex.py @@ -7,18 +7,18 @@ import binhex import os import unittest -from test import test_support +from test import support class BinHexTestCase(unittest.TestCase): def setUp(self): - self.fname1 = test_support.TESTFN + "1" - self.fname2 = test_support.TESTFN + "2" + self.fname1 = support.TESTFN + "1" + self.fname2 = support.TESTFN + "2" def tearDown(self): - test_support.unlink(self.fname1) - test_support.unlink(self.fname2) + support.unlink(self.fname1) + support.unlink(self.fname2) DATA = b'Jack is my hero' @@ -39,7 +39,7 @@ class BinHexTestCase(unittest.TestCase): def test_main(): - test_support.run_unittest(BinHexTestCase) + support.run_unittest(BinHexTestCase) if __name__ == "__main__": diff --git a/Lib/test/test_binop.py b/Lib/test/test_binop.py index f0433fb..b260b1b 100644 --- a/Lib/test/test_binop.py +++ b/Lib/test/test_binop.py @@ -1,7 +1,7 @@ """Tests for binary operators on subtypes of built-in types.""" import unittest -from test import test_support +from test import support def gcd(a, b): """Greatest common divisor using Euclid's algorithm.""" @@ -317,7 +317,7 @@ self.assertEqual(eval('1/2'), 0.5) """ def test_main(): - test_support.run_unittest(RatTestCase) + support.run_unittest(RatTestCase) if __name__ == "__main__": diff --git a/Lib/test/test_bisect.py b/Lib/test/test_bisect.py index 11495ba..af9f1f7 100644 --- a/Lib/test/test_bisect.py +++ b/Lib/test/test_bisect.py @@ -1,6 +1,6 @@ import sys import unittest -from test import test_support +from test import support from collections import UserList # We do a bit of trickery here to be able to test both the C implementation @@ -286,15 +286,15 @@ def test_main(verbose=None): TestInsortPython, TestInsortC, TestErrorHandlingPython, TestErrorHandlingC] - test_support.run_unittest(*test_classes) - test_support.run_doctest(test_bisect, verbose) + support.run_unittest(*test_classes) + support.run_doctest(test_bisect, verbose) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in range(len(counts)): - test_support.run_unittest(*test_classes) + support.run_unittest(*test_classes) gc.collect() counts[i] = sys.gettotalrefcount() print(counts) diff --git a/Lib/test/test_bool.py b/Lib/test/test_bool.py index bbaea85..591b0eb 100644 --- a/Lib/test/test_bool.py +++ b/Lib/test/test_bool.py @@ -1,7 +1,7 @@ # Test properties of bool promised by PEP 285 import unittest -from test import test_support +from test import support import os @@ -26,14 +26,14 @@ class BoolTest(unittest.TestCase): def test_print(self): try: - fo = open(test_support.TESTFN, "w") + fo = open(support.TESTFN, "w") print(False, True, file=fo) fo.close() - fo = open(test_support.TESTFN, "r") + fo = open(support.TESTFN, "r") self.assertEqual(fo.read(), 'False True\n') finally: fo.close() - os.remove(test_support.TESTFN) + os.remove(support.TESTFN) def test_repr(self): self.assertEqual(repr(False), 'False') @@ -234,12 +234,12 @@ class BoolTest(unittest.TestCase): def test_fileclosed(self): try: - f = open(test_support.TESTFN, "w") + f = open(support.TESTFN, "w") self.assertIs(f.closed, False) f.close() self.assertIs(f.closed, True) finally: - os.remove(test_support.TESTFN) + os.remove(support.TESTFN) def test_operator(self): import operator @@ -331,7 +331,7 @@ class BoolTest(unittest.TestCase): self.assertEqual(str(e_bool), str(e_len)) def test_main(): - test_support.run_unittest(BoolTest) + support.run_unittest(BoolTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_bsddb.py b/Lib/test/test_bsddb.py index dfee3dc..3eb291f 100755 --- a/Lib/test/test_bsddb.py +++ b/Lib/test/test_bsddb.py @@ -7,7 +7,7 @@ import copy import bsddb import dbhash # Just so we know it's imported import unittest -from test import test_support +from test import support class TestBSDDB(unittest.TestCase): openflag = 'c' @@ -274,7 +274,7 @@ class TestBSDDB(unittest.TestCase): self.assertEqual(list(self.f), keys) class TestBTree(TestBSDDB): - fname = test_support.TESTFN + fname = support.TESTFN openmethod = [bsddb.btopen] class TestBTree_InMemory(TestBSDDB): @@ -287,7 +287,7 @@ class TestBTree_InMemory_Truncate(TestBSDDB): openmethod = [bsddb.btopen] class TestHashTable(TestBSDDB): - fname = test_support.TESTFN + fname = support.TESTFN openmethod = [bsddb.hashopen] class TestHashTable_InMemory(TestBSDDB): @@ -299,7 +299,7 @@ class TestHashTable_InMemory(TestBSDDB): ## # Solaris Intel - rmasse 1/97 def test_main(verbose=None): - test_support.run_unittest( + support.run_unittest( TestBTree, TestHashTable, TestBTree_InMemory, diff --git a/Lib/test/test_bsddb3.py b/Lib/test/test_bsddb3.py index 1f58c12..6a277d9 100644 --- a/Lib/test/test_bsddb3.py +++ b/Lib/test/test_bsddb3.py @@ -7,7 +7,7 @@ import sys import tempfile import time import unittest -from test.test_support import requires, verbose, run_unittest, unlink, rmtree +from test.support import requires, verbose, run_unittest, unlink, rmtree # When running as a script instead of within the regrtest framework, skip the # requires test, since it's obvious we want to run them. diff --git a/Lib/test/test_bufio.py b/Lib/test/test_bufio.py index 804a401..e65951d 100644 --- a/Lib/test/test_bufio.py +++ b/Lib/test/test_bufio.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support # Simple test to ensure that optimizations in fileobject.c deliver # the expected results. For best testing, run this under a debug-build @@ -14,18 +14,18 @@ class BufferSizeTest(unittest.TestCase): # .readline()s deliver what we wrote. # Ensure we can open TESTFN for writing. - test_support.unlink(test_support.TESTFN) + support.unlink(support.TESTFN) # Since C doesn't guarantee we can write/read arbitrary bytes in text # files, use binary mode. - f = open(test_support.TESTFN, "wb") + f = open(support.TESTFN, "wb") try: # write once with \n and once without f.write(s) f.write(b"\n") f.write(s) f.close() - f = open(test_support.TESTFN, "rb") + f = open(support.TESTFN, "rb") line = f.readline() self.assertEqual(line, s + b"\n") line = f.readline() @@ -34,7 +34,7 @@ class BufferSizeTest(unittest.TestCase): self.assert_(not line) # Must be at EOF f.close() finally: - test_support.unlink(test_support.TESTFN) + support.unlink(support.TESTFN) def drive_one(self, pattern): for length in lengths: @@ -59,7 +59,7 @@ class BufferSizeTest(unittest.TestCase): self.drive_one(bytes(1000)) def test_main(): - test_support.run_unittest(BufferSizeTest) + support.run_unittest(BufferSizeTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index a74cc84..ef562db 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -1,7 +1,7 @@ # Python test set -- built-in functions -import test.test_support, unittest -from test.test_support import fcmp, TESTFN, unlink, run_unittest, \ +import test.support, unittest +from test.support import fcmp, TESTFN, unlink, run_unittest, \ run_with_locale from operator import neg diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py index 5f3580d..206dde9 100644 --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -13,7 +13,7 @@ import pickle import tempfile import unittest import warnings -import test.test_support +import test.support import test.string_tests import test.buffer_tests @@ -969,13 +969,13 @@ class ByteArraySubclassTest(unittest.TestCase): def test_main(): - test.test_support.run_unittest(BytesTest) - test.test_support.run_unittest(ByteArrayTest) - test.test_support.run_unittest(AssortedBytesTest) - test.test_support.run_unittest(BytesAsStringTest) - test.test_support.run_unittest(ByteArrayAsStringTest) - test.test_support.run_unittest(ByteArraySubclassTest) - test.test_support.run_unittest(BytearrayPEP3137Test) + test.support.run_unittest(BytesTest) + test.support.run_unittest(ByteArrayTest) + test.support.run_unittest(AssortedBytesTest) + test.support.run_unittest(BytesAsStringTest) + test.support.run_unittest(ByteArrayAsStringTest) + test.support.run_unittest(ByteArraySubclassTest) + test.support.run_unittest(BytearrayPEP3137Test) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_bz2.py b/Lib/test/test_bz2.py index 39bf19c..4646f02 100644 --- a/Lib/test/test_bz2.py +++ b/Lib/test/test_bz2.py @@ -1,6 +1,6 @@ #!/usr/bin/python -from test import test_support -from test.test_support import TESTFN +from test import support +from test.support import TESTFN import unittest from io import BytesIO @@ -333,13 +333,13 @@ class FuncTest(BaseTest): self.assertRaises(ValueError, bz2.decompress, self.DATA[:-10]) def test_main(): - test_support.run_unittest( + support.run_unittest( BZ2FileTest, BZ2CompressorTest, BZ2DecompressorTest, FuncTest ) - test_support.reap_children() + support.reap_children() if __name__ == '__main__': test_main() diff --git a/Lib/test/test_cProfile.py b/Lib/test/test_cProfile.py index 7ae0bca..913ed1a 100644 --- a/Lib/test/test_cProfile.py +++ b/Lib/test/test_cProfile.py @@ -121,7 +121,7 @@ class C: def test_main(): - from test.test_support import TestSkipped + from test.support import TestSkipped raise TestSkipped('test_cProfile test is current broken') diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py index 5f9c057..5debee9 100644 --- a/Lib/test/test_calendar.py +++ b/Lib/test/test_calendar.py @@ -1,7 +1,7 @@ import calendar import unittest -from test import test_support +from test import support result_2004_text = """ @@ -383,7 +383,7 @@ class SundayTestCase(MonthCalendarTestCase): def test_main(): - test_support.run_unittest( + support.run_unittest( OutputTestCase, CalendarTestCase, MondayTestCase, diff --git a/Lib/test/test_call.py b/Lib/test/test_call.py index 2652343..c00ccba 100644 --- a/Lib/test/test_call.py +++ b/Lib/test/test_call.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support # The test cases here cover several paths through the function calling # code. They depend on the METH_XXX flag that is used to define a C @@ -124,7 +124,7 @@ class CFunctionCalls(unittest.TestCase): def test_main(): - test_support.run_unittest(CFunctionCalls) + support.run_unittest(CFunctionCalls) if __name__ == "__main__": diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py index 87be9ee..df5ce0b 100644 --- a/Lib/test/test_capi.py +++ b/Lib/test/test_capi.py @@ -2,7 +2,7 @@ # these are all functions _testcapi exports whose name begins with 'test_'. import sys -from test import test_support +from test import support import _testcapi def test_main(): @@ -10,13 +10,13 @@ def test_main(): for name in dir(_testcapi): if name.startswith('test_'): test = getattr(_testcapi, name) - if test_support.verbose: + if support.verbose: print("internal", name) test() # some extra thread-state tests driven via _testcapi def TestThreadState(): - if test_support.verbose: + if support.verbose: print("auto-thread-state") idents = [] @@ -29,7 +29,7 @@ def test_main(): time.sleep(1) # Check our main thread is in the list exactly 3 times. if idents.count(thread.get_ident()) != 3: - raise test_support.TestFailed( + raise support.TestFailed( "Couldn't find main thread correctly in the list") try: diff --git a/Lib/test/test_cfgparser.py b/Lib/test/test_cfgparser.py index 70bf0ac..dcc1a98 100644 --- a/Lib/test/test_cfgparser.py +++ b/Lib/test/test_cfgparser.py @@ -3,7 +3,7 @@ import io import unittest import collections -from test import test_support +from test import support class SortedDict(collections.UserDict): def items(self): @@ -251,7 +251,7 @@ class TestCaseBase(unittest.TestCase): cf.set("sect", "option2", "splat") def test_read_returns_file_list(self): - file1 = test_support.findfile("cfgparser.1") + file1 = support.findfile("cfgparser.1") # check when we pass a mix of readable and non-readable files: cf = self.newconfig() parsed_files = cf.read([file1, "nonexistant-file"]) @@ -469,7 +469,7 @@ class SortedTestCase(RawConfigParserTestCase): "o4 = 1\n\n") def test_main(): - test_support.run_unittest( + support.run_unittest( ConfigParserTestCase, RawConfigParserTestCase, SafeConfigParserTestCase, diff --git a/Lib/test/test_cgi.py b/Lib/test/test_cgi.py index f28719b..f9b336f 100644 --- a/Lib/test/test_cgi.py +++ b/Lib/test/test_cgi.py @@ -1,4 +1,4 @@ -from test.test_support import run_unittest +from test.support import run_unittest import cgi import os import sys diff --git a/Lib/test/test_charmapcodec.py b/Lib/test/test_charmapcodec.py index 5e4055e..8b79bde 100644 --- a/Lib/test/test_charmapcodec.py +++ b/Lib/test/test_charmapcodec.py @@ -9,7 +9,7 @@ Written by Marc-Andre Lemburg (mal@lemburg.com). """#" -import test.test_support, unittest +import test.support, unittest import codecs @@ -50,7 +50,7 @@ class CharmapCodecTest(unittest.TestCase): self.assertRaises(UnicodeError, str, b'abc\001', codecname) def test_main(): - test.test_support.run_unittest(CharmapCodecTest) + test.support.run_unittest(CharmapCodecTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_class.py b/Lib/test/test_class.py index 730826d..cabf715 100644 --- a/Lib/test/test_class.py +++ b/Lib/test/test_class.py @@ -2,7 +2,7 @@ import unittest -from test import test_support +from test import support testmeths = [ @@ -555,7 +555,7 @@ class ClassTests(unittest.TestCase): hash(a.f) def test_main(): - test_support.run_unittest(ClassTests) + support.run_unittest(ClassTests) if __name__=='__main__': test_main() diff --git a/Lib/test/test_cmath.py b/Lib/test/test_cmath.py index ca4945d..3c34fec 100755 --- a/Lib/test/test_cmath.py +++ b/Lib/test/test_cmath.py @@ -1,4 +1,4 @@ -from test.test_support import run_unittest +from test.support import run_unittest from test.test_math import parse_testfile, test_file import unittest import os, sys diff --git a/Lib/test/test_cmd.py b/Lib/test/test_cmd.py index 2c77931..e2b3022 100644 --- a/Lib/test/test_cmd.py +++ b/Lib/test/test_cmd.py @@ -167,8 +167,8 @@ class samplecmdclass(cmd.Cmd): return True def test_main(verbose=None): - from test import test_support, test_cmd - test_support.run_doctest(test_cmd, verbose) + from test import support, test_cmd + support.run_doctest(test_cmd, verbose) def test_coverage(coverdir): tracer=trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,], diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py index 19089a4..9ccf3f5 100644 --- a/Lib/test/test_cmd_line.py +++ b/Lib/test/test_cmd_line.py @@ -2,7 +2,7 @@ # All tests are executed with environment variables ignored # See test_cmd_line_script.py for testing of script execution -import test.test_support, unittest +import test.support, unittest import sys import subprocess @@ -123,8 +123,8 @@ class CmdLineTest(unittest.TestCase): def test_main(): - test.test_support.run_unittest(CmdLineTest) - test.test_support.reap_children() + test.support.run_unittest(CmdLineTest) + test.support.reap_children() if