From ee8712cda46338d223509cc5751fd36509ad3860 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Tue, 20 May 2008 21:35:26 +0000 Subject: #2621 rename test.test_support to test.support --- Doc/library/test.rst | 10 +- Lib/bsddb/test/test_associate.py | 2 +- Lib/bsddb/test/test_basics.py | 2 +- Lib/bsddb/test/test_compare.py | 2 +- Lib/bsddb/test/test_cursor_pget_bug.py | 2 +- Lib/bsddb/test/test_dbobj.py | 2 +- Lib/bsddb/test/test_dbshelve.py | 2 +- Lib/bsddb/test/test_dbtables.py | 2 +- Lib/bsddb/test/test_env_close.py | 2 +- Lib/bsddb/test/test_join.py | 2 +- Lib/bsddb/test/test_lock.py | 2 +- Lib/bsddb/test/test_misc.py | 2 +- Lib/bsddb/test/test_pickle.py | 2 +- Lib/bsddb/test/test_recno.py | 2 +- Lib/bsddb/test/test_sequence.py | 2 +- Lib/bsddb/test/test_thread.py | 2 +- Lib/distutils/tests/test_core.py | 10 +- Lib/distutils/tests/test_dist.py | 2 +- Lib/distutils/tests/test_sysconfig.py | 2 +- Lib/email/test/test_email.py | 2 +- Lib/email/test/test_email_codecs.py | 2 +- Lib/email/test/test_email_codecs_renamed.py | 2 +- Lib/email/test/test_email_torture.py | 4 +- Lib/test/double_const.py | 2 +- Lib/test/list_tests.py | 8 +- Lib/test/outstanding_bugs.py | 6 +- Lib/test/pickletester.py | 2 +- Lib/test/regrtest.py | 31 +- Lib/test/string_tests.py | 2 +- Lib/test/support.py | 769 ++++++++++++++++++++++++++++ Lib/test/test_SimpleHTTPServer.py | 4 +- Lib/test/test___all__.py | 2 +- Lib/test/test___future__.py | 4 +- Lib/test/test__locale.py | 2 +- Lib/test/test_abc.py | 4 +- Lib/test/test_abstract_numbers.py | 4 +- Lib/test/test_anydbm.py | 6 +- Lib/test/test_array.py | 14 +- Lib/test/test_ast.py | 4 +- Lib/test/test_asynchat.py | 8 +- Lib/test/test_asyncore.py | 8 +- Lib/test/test_atexit.py | 4 +- Lib/test/test_audioop.py | 2 +- Lib/test/test_augassign.py | 2 +- Lib/test/test_base64.py | 4 +- Lib/test/test_bigaddrspace.py | 8 +- Lib/test/test_bigmem.py | 8 +- Lib/test/test_binascii.py | 4 +- Lib/test/test_binhex.py | 12 +- Lib/test/test_binop.py | 4 +- Lib/test/test_bisect.py | 8 +- Lib/test/test_bool.py | 14 +- Lib/test/test_bsddb.py | 8 +- Lib/test/test_bsddb3.py | 2 +- Lib/test/test_bufio.py | 12 +- Lib/test/test_builtin.py | 4 +- Lib/test/test_bytes.py | 16 +- Lib/test/test_bz2.py | 8 +- Lib/test/test_cProfile.py | 2 +- Lib/test/test_calendar.py | 4 +- Lib/test/test_call.py | 4 +- Lib/test/test_capi.py | 8 +- Lib/test/test_cfgparser.py | 6 +- Lib/test/test_cgi.py | 2 +- Lib/test/test_charmapcodec.py | 4 +- Lib/test/test_class.py | 4 +- Lib/test/test_cmath.py | 2 +- Lib/test/test_cmd.py | 4 +- Lib/test/test_cmd_line.py | 6 +- Lib/test/test_cmd_line_script.py | 10 +- Lib/test/test_code.py | 2 +- Lib/test/test_codeccallbacks.py | 4 +- Lib/test/test_codecencodings_cn.py | 4 +- Lib/test/test_codecencodings_hk.py | 4 +- Lib/test/test_codecencodings_jp.py | 4 +- Lib/test/test_codecencodings_kr.py | 4 +- Lib/test/test_codecencodings_tw.py | 4 +- Lib/test/test_codecmaps_cn.py | 4 +- Lib/test/test_codecmaps_hk.py | 6 +- Lib/test/test_codecmaps_jp.py | 4 +- Lib/test/test_codecmaps_kr.py | 4 +- Lib/test/test_codecmaps_tw.py | 4 +- Lib/test/test_codecs.py | 6 +- Lib/test/test_codeop.py | 2 +- Lib/test/test_coding.py | 6 +- Lib/test/test_collections.py | 6 +- Lib/test/test_colorsys.py | 4 +- Lib/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 __name__ == "__main__": test_main() diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py index 74031c9..e0b09ea 100644 --- a/Lib/test/test_cmd_line_script.py +++ b/Lib/test/test_cmd_line_script.py @@ -4,7 +4,7 @@ import unittest import os import os.path import sys -import test.test_support +import test.support import tempfile import subprocess import py_compile @@ -12,9 +12,9 @@ import contextlib import shutil import zipfile -verbose = test.test_support.verbose +verbose = test.support.verbose -# XXX ncoghlan: Should we consider moving these to test_support? +# XXX ncoghlan: Should we consider moving these to support? from test.test_cmd_line import _spawn_python, _kill_python def _run_python(*args): @@ -176,8 +176,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 __name__ == '__main__': test_main() diff --git a/Lib/test/test_code.py b/Lib/test/test_code.py index 63378c2..c8fa2a1 100644 --- a/Lib/test/test_code.py +++ b/Lib/test/test_code.py @@ -119,7 +119,7 @@ def dump(co): print("consts:", tuple(consts(co.co_consts))) def test_main(verbose=None): - from test.test_support import run_doctest + from test.support import run_doctest from test import test_code run_doctest(test_code, verbose) diff --git a/Lib/test/test_codeccallbacks.py b/Lib/test/test_codeccallbacks.py index 64d1645..d1a4868 100644 --- a/Lib/test/test_codeccallbacks.py +++ b/Lib/test/test_codeccallbacks.py @@ -1,4 +1,4 @@ -import test.test_support, unittest +import test.support, unittest import sys, codecs, html.entities, unicodedata class PosReturn: @@ -843,7 +843,7 @@ class CodecCallbackTest(unittest.TestCase): self.assertRaises(TypeError, data.decode, encoding, "test.replacing") def test_main(): - test.test_support.run_unittest(CodecCallbackTest) + test.support.run_unittest(CodecCallbackTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_codecencodings_cn.py b/Lib/test/test_codecencodings_cn.py index bc1d7ad..77bac13 100644 --- a/Lib/test/test_codecencodings_cn.py +++ b/Lib/test/test_codecencodings_cn.py @@ -4,7 +4,7 @@ # Codec encoding tests for PRC encodings. # -from test import test_support +from test import support from test import test_multibytecodec_support import unittest @@ -51,7 +51,7 @@ class Test_GB18030(test_multibytecodec_support.TestBase, unittest.TestCase): has_iso10646 = True def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_codecencodings_hk.py b/Lib/test/test_codecencodings_hk.py index c8e7941..b1deb71 100644 --- a/Lib/test/test_codecencodings_hk.py +++ b/Lib/test/test_codecencodings_hk.py @@ -4,7 +4,7 @@ # Codec encoding tests for HongKong encodings. # -from test import test_support +from test import support from test import test_multibytecodec_support import unittest @@ -21,7 +21,7 @@ class Test_Big5HKSCS(test_multibytecodec_support.TestBase, 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_codecencodings_jp.py b/Lib/test/test_codecencodings_jp.py index 5d939a6..e2cd7d7 100644 --- a/Lib/test/test_codecencodings_jp.py +++ b/Lib/test/test_codecencodings_jp.py @@ -4,7 +4,7 @@ # Codec encoding tests for Japanese encodings. # -from test import test_support +from test import support from test import test_multibytecodec_support import unittest @@ -99,7 +99,7 @@ class Test_SJISX0213(test_multibytecodec_support.TestBase, 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_codecencodings_kr.py b/Lib/test/test_codecencodings_kr.py index 18ed393..34fade9 100644 --- a/Lib/test/test_codecencodings_kr.py +++ b/Lib/test/test_codecencodings_kr.py @@ -4,7 +4,7 @@ # Codec encoding tests for ROK encodings. # -from test import test_support +from test import support from test import test_multibytecodec_support import unittest @@ -63,7 +63,7 @@ class Test_JOHAB(test_multibytecodec_support.TestBase, 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_codecencodings_tw.py b/Lib/test/test_codecencodings_tw.py index bb7fd38..6b840d3 100644 --- a/Lib/test/test_codecencodings_tw.py +++ b/Lib/test/test_codecencodings_tw.py @@ -4,7 +4,7 @@ # Codec encoding tests for ROC encodings. # -from test import test_support +from test import support from test import test_multibytecodec_support import unittest @@ -21,7 +21,7 @@ class Test_Big5(test_multibytecodec_support.TestBase, 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_codecmaps_cn.py b/Lib/test/test_codecmaps_cn.py index 344fc56..34a910d 100644 --- a/Lib/test/test_codecmaps_cn.py +++ b/Lib/test/test_codecmaps_cn.py @@ -4,7 +4,7 @@ # Codec mapping tests for PRC encodings # -from test import test_support +from test import support from test import test_multibytecodec_support import unittest @@ -27,7 +27,7 @@ class TestGB18030Map(test_multibytecodec_support.TestBase_Mapping, def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_codecmaps_hk.py b/Lib/test/test_codecmaps_hk.py index 362ab7f..ddb1208 100644 --- a/Lib/test/test_codecmaps_hk.py +++ b/Lib/test/test_codecmaps_hk.py @@ -4,7 +4,7 @@ # Codec mapping tests for HongKong encodings # -from test import test_support +from test import support from test import test_multibytecodec_support import unittest @@ -14,8 +14,8 @@ class TestBig5HKSCSMap(test_multibytecodec_support.TestBase_Mapping, mapfileurl = 'http://people.freebsd.org/~perky/i18n/BIG5HKSCS-2004.TXT' def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": - test_support.use_resources = ['urlfetch'] + support.use_resources = ['urlfetch'] test_main() diff --git a/Lib/test/test_codecmaps_jp.py b/Lib/test/test_codecmaps_jp.py index dec97fb..75db00c 100644 --- a/Lib/test/test_codecmaps_jp.py +++ b/Lib/test/test_codecmaps_jp.py @@ -4,7 +4,7 @@ # Codec mapping tests for Japanese encodings # -from test import test_support +from test import support from test import test_multibytecodec_support import unittest @@ -61,7 +61,7 @@ class TestSJISX0213Map(test_multibytecodec_support.TestBase_Mapping, def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_codecmaps_kr.py b/Lib/test/test_codecmaps_kr.py index f9c97e5..0da9d1c 100644 --- a/Lib/test/test_codecmaps_kr.py +++ b/Lib/test/test_codecmaps_kr.py @@ -4,7 +4,7 @@ # Codec mapping tests for ROK encodings # -from test import test_support +from test import support from test import test_multibytecodec_support import unittest @@ -38,7 +38,7 @@ class TestJOHABMap(test_multibytecodec_support.TestBase_Mapping, pass_dectest = [(b'\\', '\u20a9')] def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_codecmaps_tw.py b/Lib/test/test_codecmaps_tw.py index 4bd1966..e6df3a7 100644 --- a/Lib/test/test_codecmaps_tw.py +++ b/Lib/test/test_codecmaps_tw.py @@ -4,7 +4,7 @@ # Codec mapping tests for ROC encodings # -from test import test_support +from test import support from test import test_multibytecodec_support import unittest @@ -25,7 +25,7 @@ class TestCP950Map(test_multibytecodec_support.TestBase_Mapping, ] def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py index a828edf..a7da809 100644 --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -1,4 +1,4 @@ -from test import test_support +from test import support import unittest import codecs import sys, _testcapi, io @@ -1032,7 +1032,7 @@ class NameprepTest(unittest.TestCase): try: self.assertEquals(nameprep(orig), prepped) except Exception as e: - raise test_support.TestFailed("Test 3.%d: %s" % (pos+1, str(e))) + raise support.TestFailed("Test 3.%d: %s" % (pos+1, str(e))) class IDNACodecTest(unittest.TestCase): def test_builtin_decode(self): @@ -1477,7 +1477,7 @@ class WithStmtTest(unittest.TestCase): def test_main(): - test_support.run_unittest( + support.run_unittest( UTF32Test, UTF32LETest, UTF32BETest, diff --git a/Lib/test/test_codeop.py b/Lib/test/test_codeop.py index edea601..224a314 100644 --- a/Lib/test/test_codeop.py +++ b/Lib/test/test_codeop.py @@ -3,7 +3,7 @@ Nick Mathewson """ import unittest -from test.test_support import run_unittest, is_jython +from test.support import run_unittest, is_jython from codeop import compile_command, PyCF_DONT_IMPLY_DEDENT import io diff --git a/Lib/test/test_coding.py b/Lib/test/test_coding.py index b1664f4..ade8bdf 100644 --- a/Lib/test/test_coding.py +++ b/Lib/test/test_coding.py @@ -1,6 +1,6 @@ -import test.test_support, unittest -from test.test_support import TESTFN, unlink +import test.support, unittest +from test.support import TESTFN, unlink import os, sys class CodingTest(unittest.TestCase): @@ -50,7 +50,7 @@ class CodingTest(unittest.TestCase): sys.path.pop(0) def test_main(): - test.test_support.run_unittest(CodingTest) + test.support.run_unittest(CodingTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py index 9384744..ad8c230 100644 --- a/Lib/test/test_collections.py +++ b/Lib/test/test_collections.py @@ -1,7 +1,7 @@ """Unit tests for collections.py.""" import unittest, doctest -from test import test_support +from test import support from collections import namedtuple from collections import Hashable, Iterable, Iterator from collections import Sized, Container, Callable @@ -321,8 +321,8 @@ import doctest, collections def test_main(verbose=None): NamedTupleDocs = doctest.DocTestSuite(module=collections) test_classes = [TestNamedTuple, NamedTupleDocs, TestOneTrickPonyABCs, TestCollectionABCs] - test_support.run_unittest(*test_classes) - test_support.run_doctest(collections, verbose) + support.run_unittest(*test_classes) + support.run_doctest(collections, verbose) if __name__ == "__main__": diff --git a/Lib/test/test_colorsys.py b/Lib/test/test_colorsys.py index a8cd885..e405b8a 100644 --- a/Lib/test/test_colorsys.py +++ b/Lib/test/test_colorsys.py @@ -1,4 +1,4 @@ -import unittest, test.test_support +import unittest, test.support import colorsys def frange(start, stop, step): @@ -70,7 +70,7 @@ class ColorsysTest(unittest.TestCase): self.assertTripleEqual(rgb, colorsys.hls_to_rgb(*hls)) def test_main(): - test.test_support.run_unittest(ColorsysTest) + test.support.run_unittest(ColorsysTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_commands.py b/Lib/test/test_commands.py index 1b84306..b4e48ce 100644 --- a/Lib/test/test_commands.py +++ b/Lib/test/test_commands.py @@ -5,7 +5,7 @@ import unittest import os, tempfile, re -from test.test_support import TestSkipped, run_unittest, reap_children +from test.support import TestSkipped, run_unittest, reap_children from commands import * # The module says: diff --git a/Lib/test/test_compare.py b/Lib/test/test_compare.py index de32f3c..ee3794a 100644 --- a/Lib/test/test_compare.py +++ b/Lib/test/test_compare.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support class Empty: def __repr__(self): @@ -61,7 +61,7 @@ class ComparisonTest(unittest.TestCase): def test_main(): - test_support.run_unittest(ComparisonTest) + support.run_unittest(ComparisonTest) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py index 5a069d3..2462269 100644 --- a/Lib/test/test_compile.py +++ b/Lib/test/test_compile.py @@ -1,7 +1,7 @@ import unittest import sys import _ast -from test import test_support +from test import support class TestSpecifics(unittest.TestCase): @@ -444,7 +444,7 @@ if 1: def test_main(): - test_support.run_unittest(TestSpecifics) + support.run_unittest(TestSpecifics) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_complex.py b/Lib/test/test_complex.py index fbed4f2..44c8999 100644 --- a/Lib/test/test_complex.py +++ b/Lib/test/test_complex.py @@ -1,5 +1,5 @@ import unittest, os -from test import test_support +from test import support from random import random from math import atan2 @@ -339,16 +339,16 @@ class ComplexTest(unittest.TestCase): fo = None try: - fo = open(test_support.TESTFN, "w") + fo = open(support.TESTFN, "w") print(a, b, file=fo) fo.close() - fo = open(test_support.TESTFN, "r") + fo = open(support.TESTFN, "r") self.assertEqual(fo.read(), ("%s %s\n" % (a, b))) finally: if (fo is not None) and (not fo.closed): fo.close() try: - os.remove(test_support.TESTFN) + os.remove(support.TESTFN) except (OSError, IOError): pass @@ -360,7 +360,7 @@ class ComplexTest(unittest.TestCase): self.assertEquals(atan2(z2.imag, -1.), atan2(-0., -1.)) def test_main(): - test_support.run_unittest(ComplexTest) + support.run_unittest(ComplexTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_contains.py b/Lib/test/test_contains.py index 5ab80e4..e570787 100644 --- a/Lib/test/test_contains.py +++ b/Lib/test/test_contains.py @@ -1,4 +1,4 @@ -from test.test_support import run_unittest +from test.support import run_unittest import unittest diff --git a/Lib/test/test_contextlib.py b/Lib/test/test_contextlib.py index 51d2436..c05f37b 100644 --- a/Lib/test/test_contextlib.py +++ b/Lib/test/test_contextlib.py @@ -8,7 +8,7 @@ import tempfile import unittest import threading from contextlib import * # Tests __all__ -from test import test_support +from test import support class ContextManagerTestCase(unittest.TestCase): @@ -331,7 +331,7 @@ class LockContextTestCase(unittest.TestCase): # This is needed to make the test actually run under regrtest.py! def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_cookie.py b/Lib/test/test_cookie.py index e4c8975..07d29e1 100644 --- a/Lib/test/test_cookie.py +++ b/Lib/test/test_cookie.py @@ -1,6 +1,6 @@ # Simple test suite for Cookie.py -from test.test_support import run_unittest, run_doctest +from test.support import run_unittest, run_doctest import unittest import Cookie diff --git a/Lib/test/test_cookielib.py b/Lib/test/test_cookielib.py index 87f118d..e400bfa 100644 --- a/Lib/test/test_cookielib.py +++ b/Lib/test/test_cookielib.py @@ -3,7 +3,7 @@ import re, os, time from unittest import TestCase -from test import test_support +from test import support class DateTimeTests(TestCase): @@ -234,7 +234,7 @@ class FileCookieJarTests(TestCase): def test_lwp_valueless_cookie(self): # cookies with no value should be saved and loaded consistently from cookielib import LWPCookieJar - filename = test_support.TESTFN + filename = support.TESTFN c = LWPCookieJar() interact_netscape(c, "http://www.acme.com/", 'boo') self.assertEqual(c._cookies["www.acme.com"]["/"]["boo"].value, None) @@ -250,7 +250,7 @@ class FileCookieJarTests(TestCase): def test_bad_magic(self): from cookielib import LWPCookieJar, MozillaCookieJar, LoadError # IOErrors (eg. file doesn't exist) are allowed to propagate - filename = test_support.TESTFN + filename = support.TESTFN for cookiejar_class in LWPCookieJar, MozillaCookieJar: c = cookiejar_class() try: @@ -356,7 +356,7 @@ class CookieTests(TestCase): # missing = sign in Cookie: header is regarded by Mozilla as a missing # name, and by cookielib as a missing value - filename = test_support.TESTFN + filename = support.TESTFN c = MozillaCookieJar(filename) interact_netscape(c, "http://www.acme.com/", 'eggs') interact_netscape(c, "http://www.acme.com/", '"spam"; path=/foo/') @@ -1505,7 +1505,7 @@ class LWPCookieTests(TestCase): self.assertEquals(len(c), 6) # save and restore - filename = test_support.TESTFN + filename = support.TESTFN try: c.save(filename, ignore_discard=True) @@ -1547,7 +1547,7 @@ class LWPCookieTests(TestCase): year_plus_one = time.localtime()[0] + 1 - filename = test_support.TESTFN + filename = support.TESTFN c = MozillaCookieJar(filename, policy=DefaultCookiePolicy(rfc2965=True)) @@ -1722,7 +1722,7 @@ class LWPCookieTests(TestCase): def test_main(verbose=None): - test_support.run_unittest( + support.run_unittest( DateTimeTests, HeaderTests, CookieTests, diff --git a/Lib/test/test_copy.py b/Lib/test/test_copy.py index 182b8c3..500fa83 100644 --- a/Lib/test/test_copy.py +++ b/Lib/test/test_copy.py @@ -4,7 +4,7 @@ import copy import copyreg import unittest -from test import test_support +from test import support class TestCopy(unittest.TestCase): @@ -50,7 +50,7 @@ class TestCopy(unittest.TestCase): def __reduce_ex__(self, proto): return "" def __reduce__(self): - raise test_support.TestFailed("shouldn't call this") + raise support.TestFailed("shouldn't call this") x = C() y = copy.copy(x) self.assert_(y is x) @@ -223,7 +223,7 @@ class TestCopy(unittest.TestCase): def __reduce_ex__(self, proto): return "" def __reduce__(self): - raise test_support.TestFailed("shouldn't call this") + raise support.TestFailed("shouldn't call this") x = C() y = copy.deepcopy(x) self.assert_(y is x) @@ -584,7 +584,7 @@ class TestCopy(unittest.TestCase): def global_foo(x, y): return x+y def test_main(): - test_support.run_unittest(TestCopy) + support.run_unittest(TestCopy) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_copyreg.py b/Lib/test/test_copyreg.py index 82f6c94..48e58ea 100644 --- a/Lib/test/test_copyreg.py +++ b/Lib/test/test_copyreg.py @@ -1,7 +1,7 @@ import copyreg import unittest -from test import test_support +from test import support from test.pickletester import ExtensionSaver class C: @@ -114,7 +114,7 @@ class CopyRegTestCase(unittest.TestCase): def test_main(): - test_support.run_unittest(CopyRegTestCase) + support.run_unittest(CopyRegTestCase) if __name__ == "__main__": diff --git a/Lib/test/test_crypt.py b/Lib/test/test_crypt.py index aa07f49..b4d0ac9 100755 --- a/Lib/test/test_crypt.py +++ b/Lib/test/test_crypt.py @@ -1,4 +1,4 @@ -from test import test_support +from test import support import unittest import crypt @@ -6,11 +6,11 @@ class CryptTestCase(unittest.TestCase): def test_crypt(self): c = crypt.crypt('mypassword', 'ab') - if test_support.verbose: + if support.verbose: print('Test encryption: ', c) def test_main(): - test_support.run_unittest(CryptTestCase) + support.run_unittest(CryptTestCase) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_csv.py b/Lib/test/test_csv.py index f53c5ea..1dbb71a 100644 --- a/Lib/test/test_csv.py +++ b/Lib/test/test_csv.py @@ -10,7 +10,7 @@ from io import StringIO, BytesIO from tempfile import TemporaryFile import csv import gc -from test import test_support +from test import support class Test_Csv(unittest.TestCase): """ @@ -790,7 +790,7 @@ Stonecutters Seafood and Chop House, Lemont, IL, 12/19/02, Week Back self.assertEqual(dialect.quotechar, "'") if not hasattr(sys, "gettotalrefcount"): - if test_support.verbose: print("*** skipping leakage tests ***") + if support.verbose: print("*** skipping leakage tests ***") else: class NUL: def write(s, *args): @@ -891,7 +891,7 @@ class TestUnicode(unittest.TestCase): def test_main(): mod = sys.modules[__name__] - test_support.run_unittest( + support.run_unittest( *[getattr(mod, name) for name in dir(mod) if name.startswith('Test')] ) diff --git a/Lib/test/test_ctypes.py b/Lib/test/test_ctypes.py index 7a81ab4..92c98ad 100644 --- a/Lib/test/test_ctypes.py +++ b/Lib/test/test_ctypes.py @@ -1,6 +1,6 @@ import unittest -from test.test_support import run_unittest +from test.support import run_unittest import ctypes.test def test_main(): diff --git a/Lib/test/test_curses.py b/Lib/test/test_curses.py index d50d81d..ebeb926 100644 --- a/Lib/test/test_curses.py +++ b/Lib/test/test_curses.py @@ -16,7 +16,7 @@ import curses.panel # 'curses' resource be given on the regrtest command line using the -u # option. If not available, nothing after this line will be executed. -from test.test_support import requires, TestSkipped +from test.support import requires, TestSkipped requires('curses') # XXX: if newterm was supported we could use it instead of initscr and not exit diff --git a/Lib/test/test_datetime.py b/Lib/test/test_datetime.py index e83048e..2048fa0 100644 --- a/Lib/test/test_datetime.py +++ b/Lib/test/test_datetime.py @@ -7,7 +7,7 @@ import os import pickle import unittest -from test import test_support +from test import support from datetime import MINYEAR, MAXYEAR from datetime import timedelta @@ -3340,7 +3340,7 @@ class Oddballs(unittest.TestCase): self.assertEqual(datetime_sc, as_datetime) def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_dbm.py b/Lib/test/test_dbm.py index 44b712c..2c6ce99 100755 --- a/Lib/test/test_dbm.py +++ b/Lib/test/test_dbm.py @@ -1,4 +1,4 @@ -from test import test_support +from test import support import unittest import os import random @@ -8,13 +8,13 @@ from dbm import error class DbmTestCase(unittest.TestCase): def setUp(self): - self.filename = test_support.TESTFN + self.filename = support.TESTFN self.d = dbm.open(self.filename, 'c') self.d.close() def tearDown(self): for suffix in ['', '.pag', '.dir', '.db']: - test_support.unlink(self.filename + suffix) + support.unlink(self.filename + suffix) def test_keys(self): self.d = dbm.open(self.filename, 'c') @@ -34,7 +34,7 @@ class DbmTestCase(unittest.TestCase): self.fail() def test_main(): - test_support.run_unittest(DbmTestCase) + support.run_unittest(DbmTestCase) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py index b4f942e..617f4d9 100644 --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -30,7 +30,7 @@ import os, sys import pickle, copy import unittest from decimal import * -from test.test_support import (TestSkipped, run_unittest, run_doctest, +from test.support import (TestSkipped, run_unittest, run_doctest, is_resource_enabled) import random try: diff --git a/Lib/test/test_decorators.py b/Lib/test/test_decorators.py index 1499004..53c9469 100644 --- a/Lib/test/test_decorators.py +++ b/Lib/test/test_decorators.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support def funcattrs(**kwds): def decorate(func): @@ -302,8 +302,8 @@ class TestClassDecorators(unittest.TestCase): self.assertEqual(C.extra, 'second') def test_main(): - test_support.run_unittest(TestDecorators) - test_support.run_unittest(TestClassDecorators) + support.run_unittest(TestDecorators) + support.run_unittest(TestClassDecorators) if __name__=="__main__": test_main() diff --git a/Lib/test/test_defaultdict.py b/Lib/test/test_defaultdict.py index 065cc10..49519ab 100644 --- a/Lib/test/test_defaultdict.py +++ b/Lib/test/test_defaultdict.py @@ -4,7 +4,7 @@ import os import copy import tempfile import unittest -from test import test_support +from test import support from collections import defaultdict @@ -166,7 +166,7 @@ class TestDefaultDict(unittest.TestCase): def test_main(): - test_support.run_unittest(TestDefaultDict) + support.run_unittest(TestDefaultDict) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_deque.py b/Lib/test/test_deque.py index cb59579..1ac43da 100644 --- a/Lib/test/test_deque.py +++ b/Lib/test/test_deque.py @@ -1,6 +1,6 @@ from collections import deque import unittest -from test import test_support, seq_tests +from test import support, seq_tests from weakref import proxy import copy import pickle @@ -64,28 +64,28 @@ class TestBasic(unittest.TestCase): self.assertEqual(list(d), [7, 8, 9]) d = deque(range(200), maxlen=10) d.append(d) - test_support.unlink(test_support.TESTFN) - fo = open(test_support.TESTFN, "w") + support.unlink(support.TESTFN) + fo = open(support.TESTFN, "w") try: 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() - test_support.unlink(test_support.TESTFN) + support.unlink(support.TESTFN) d = deque(range(10), maxlen=None) self.assertEqual(repr(d), 'deque([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])') - fo = open(test_support.TESTFN, "w") + fo = open(support.TESTFN, "w") try: 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() - test_support.unlink(test_support.TESTFN) + support.unlink(support.TESTFN) def test_comparisons(self): d = deque('xabc'); d.popleft() @@ -284,15 +284,15 @@ class TestBasic(unittest.TestCase): d = deque(range(200)) d.append(d) try: - test_support.unlink(test_support.TESTFN) - fo = open(test_support.TESTFN, "w") + support.unlink(support.TESTFN) + fo = open(support.TESTFN, "w") print(d, file=fo, end='') fo.close() - fo = open(test_support.TESTFN, "r") + fo = open(support.TESTFN, "r") self.assertEqual(fo.read(), repr(d)) finally: fo.close() - test_support.unlink(test_support.TESTFN) + support.unlink(support.TESTFN) def test_init(self): self.assertRaises(TypeError, deque, 'abc', 2, 3); @@ -670,21 +670,21 @@ def test_main(verbose=None): TestSubclassWithKwargs, ) - test_support.run_unittest(*test_classes) + support.run_unittest(*test_classes) # 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) # doctests from test import test_deque - test_support.run_doctest(test_deque, verbose) + support.run_doctest(test_deque, verbose) if __name__ == "__main__": test_main(verbose=True) diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index 288afd4..ad649cb 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -3,7 +3,7 @@ import unittest import warnings from copy import deepcopy -from test import test_support +from test import support class OperatorsTest(unittest.TestCase): @@ -2449,12 +2449,12 @@ order (MRO) for bases """ ## self.ateof = 1 ## return s ## - ## f = file(name=test_support.TESTFN, mode='w') + ## f = file(name=support.TESTFN, mode='w') ## lines = ['a\n', 'b\n', 'c\n'] ## try: ## f.writelines(lines) ## f.close() - ## f = CountedInput(test_support.TESTFN) + ## f = CountedInput(support.TESTFN) ## for (i, expected) in zip(range(1, 5) + [4], lines + 2 * [""]): ## got = f.readline() ## self.assertEqual(expected, got) @@ -2466,7 +2466,7 @@ order (MRO) for bases """ ## f.close() ## except: ## pass - ## test_support.unlink(test_support.TESTFN) + ## support.unlink(support.TESTFN) def test_keywords(self): # Testing keyword args to basic type constructors ... @@ -4093,7 +4093,7 @@ class PTypesLongInitTest(unittest.TestCase): def test_main(): # Run all local test cases, with PTypesLongInitTest first. - test_support.run_unittest(PTypesLongInitTest, OperatorsTest, + support.run_unittest(PTypesLongInitTest, OperatorsTest, ClassPropertiesAndMethods, DictProxyTests) if __name__ == "__main__": diff --git a/Lib/test/test_descrtut.py b/Lib/test/test_descrtut.py index 1ddab0e..bd298bd 100644 --- a/Lib/test/test_descrtut.py +++ b/Lib/test/test_descrtut.py @@ -8,7 +8,7 @@ # of much interest anymore), and a few were fiddled to make the output # deterministic. -from test.test_support import sortdict +from test.support import sortdict import pprint class defaultdict(dict): @@ -473,8 +473,8 @@ def test_main(verbose=None): # into the doctest examples, and unless the full test.test_descrtut # business is used the name can change depending on how the test is # invoked. - from test import test_support, test_descrtut - test_support.run_doctest(test_descrtut, verbose) + from test import support, test_descrtut + support.run_doctest(test_descrtut, verbose) # This part isn't needed for regrtest, but for running the test directly. if __name__ == "__main__": diff --git a/Lib/test/test_dict.py b/Lib/test/test_dict.py index 01d47da..b518a0b 100644 --- a/Lib/test/test_dict.py +++ b/Lib/test/test_dict.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support import sys, collections, random, string @@ -651,7 +651,7 @@ class SubclassMappingTests(mapping_tests.BasicTestMappingProtocol): type2test = Dict def test_main(): - test_support.run_unittest( + support.run_unittest( DictTest, GeneralMappingTests, SubclassMappingTests, diff --git a/Lib/test/test_dictcomps.py b/Lib/test/test_dictcomps.py index 9af9e48..a3b22dc 100644 --- a/Lib/test/test_dictcomps.py +++ b/Lib/test/test_dictcomps.py @@ -36,16 +36,16 @@ __test__ = {'doctests' : doctests} def test_main(verbose=None): import sys - from test import test_support + from test import support from test import test_dictcomps - test_support.run_doctest(test_dictcomps, verbose) + support.run_doctest(test_dictcomps, verbose) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in range(len(counts)): - test_support.run_doctest(test_dictcomps, verbose) + support.run_doctest(test_dictcomps, verbose) gc.collect() counts[i] = sys.gettotalrefcount() print(counts) diff --git a/Lib/test/test_dictviews.py b/Lib/test/test_dictviews.py index 3a5fce6..34883d2 100644 --- a/Lib/test/test_dictviews.py +++ b/Lib/test/test_dictviews.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support class DictSetTest(unittest.TestCase): @@ -70,7 +70,7 @@ class DictSetTest(unittest.TestCase): self.assertEqual(len(values), 2) def test_main(): - test_support.run_unittest(DictSetTest) + support.run_unittest(DictSetTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_difflib.py b/Lib/test/test_difflib.py index b5168dd..8425a20 100644 --- a/Lib/test/test_difflib.py +++ b/Lib/test/test_difflib.py @@ -1,5 +1,5 @@ import difflib -from test.test_support import run_unittest, findfile +from test.support import run_unittest, findfile import unittest import doctest import sys diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py index ceb7509..cf62ecf 100644 --- a/Lib/test/test_dis.py +++ b/Lib/test/test_dis.py @@ -1,6 +1,6 @@ # Minimal tests for dis module -from test.test_support import run_unittest +from test.support import run_unittest import unittest import sys import dis diff --git a/Lib/test/test_distutils.py b/Lib/test/test_distutils.py index fcd792d..94e59bc 100644 --- a/Lib/test/test_distutils.py +++ b/Lib/test/test_distutils.py @@ -6,11 +6,11 @@ be run. """ import distutils.tests -import test.test_support +import test.support def test_main(): - test.test_support.run_unittest(distutils.tests.test_suite()) + test.support.run_unittest(distutils.tests.test_suite()) if __name__ == "__main__": diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py index af70162..f07da75 100644 --- a/Lib/test/test_doctest.py +++ b/Lib/test/test_doctest.py @@ -2,7 +2,7 @@ Test script for doctest. """ -from test import test_support +from test import support import doctest import warnings @@ -2291,10 +2291,10 @@ using the optional keyword argument `encoding`: def test_main(): # Check the doctest cases in doctest itself: - test_support.run_doctest(doctest, verbosity=True) + support.run_doctest(doctest, verbosity=True) # Check the doctest cases defined here: from test import test_doctest - test_support.run_doctest(test_doctest, verbosity=True) + support.run_doctest(test_doctest, verbosity=True) import trace, sys, re, io def test_coverage(coverdir): diff --git a/Lib/test/test_doctest2.py b/Lib/test/test_doctest2.py index eb39ab9..86334d7 100644 --- a/Lib/test/test_doctest2.py +++ b/Lib/test/test_doctest2.py @@ -12,7 +12,7 @@ the example. It should be ignored: """ -from test import test_support +from test import support class C(object): """Class C. @@ -107,9 +107,9 @@ class C(object): def test_main(): from test import test_doctest2 EXPECTED = 19 - f, t = test_support.run_doctest(test_doctest2) + f, t = support.run_doctest(test_doctest2) if t != EXPECTED: - raise test_support.TestFailed("expected %d tests to run, not %d" % + raise support.TestFailed("expected %d tests to run, not %d" % (EXPECTED, t)) # Pollute the namespace with a bunch of imported functions and classes, diff --git a/Lib/test/test_docxmlrpc.py b/Lib/test/test_docxmlrpc.py index c9984b3..2af2071 100644 --- a/Lib/test/test_docxmlrpc.py +++ b/Lib/test/test_docxmlrpc.py @@ -1,6 +1,6 @@ from DocXMLRPCServer import DocXMLRPCServer import httplib -from test import test_support +from test import support import threading import time import unittest @@ -145,7 +145,7 @@ b"""
system.methodHelp( response.read()) def test_main(): - test_support.run_unittest(DocXMLRPCHTTPGETServer) + support.run_unittest(DocXMLRPCHTTPGETServer) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_dumbdbm.py b/Lib/test/test_dumbdbm.py index 9a2cb68..24c178f 100644 --- a/Lib/test/test_dumbdbm.py +++ b/Lib/test/test_dumbdbm.py @@ -7,9 +7,9 @@ import io import os import unittest import dumbdbm -from test import test_support +from test import support -_fname = test_support.TESTFN +_fname = support.TESTFN def _delete_files(): for ext in [".dir", ".dat", ".bak"]: @@ -177,7 +177,7 @@ class DumbDBMTestCase(unittest.TestCase): def test_main(): try: - test_support.run_unittest(DumbDBMTestCase) + support.run_unittest(DumbDBMTestCase) finally: _delete_files() diff --git a/Lib/test/test_dummy_thread.py b/Lib/test/test_dummy_thread.py index 5910458..585711f 100644 --- a/Lib/test/test_dummy_thread.py +++ b/Lib/test/test_dummy_thread.py @@ -10,7 +10,7 @@ import time import queue import random import unittest -from test import test_support +from test import support DELAY = 0 # Set > 0 when testing a module other than dummy_thread, such as # the 'thread' module. @@ -71,13 +71,13 @@ class LockTests(unittest.TestCase): self.lock.acquire() start_time = int(time.time()) _thread.start_new_thread(delay_unlock,(self.lock, DELAY)) - if test_support.verbose: + if support.verbose: print() print("*** Waiting for thread to release the lock "\ "(approx. %s sec.) ***" % DELAY) self.lock.acquire() end_time = int(time.time()) - if test_support.verbose: + if support.verbose: print("done") self.failUnless((end_time - start_time) >= DELAY, "Blocking by unconditional acquiring failed.") @@ -149,7 +149,7 @@ class ThreadTests(unittest.TestCase): thread_count = 5 testing_queue = queue.Queue(thread_count) - if test_support.verbose: + if support.verbose: print() print("*** Testing multiple thread creation "\ "(will take approx. %s to %s sec.) ***" % (DELAY, thread_count)) @@ -161,7 +161,7 @@ class ThreadTests(unittest.TestCase): _thread.start_new_thread(queue_mark, (testing_queue, local_delay)) time.sleep(DELAY) - if test_support.verbose: + if support.verbose: print('done') self.failUnless(testing_queue.qsize() == thread_count, "Not all %s threads executed properly after %s sec." % @@ -172,10 +172,10 @@ def test_main(imported_module=None): if imported_module: _thread = imported_module DELAY = 2 - if test_support.verbose: + if support.verbose: print() print("*** Using %s as _thread module ***" % _thread) - test_support.run_unittest(LockTests, MiscTests, ThreadTests) + support.run_unittest(LockTests, MiscTests, ThreadTests) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_dummy_threading.py b/Lib/test/test_dummy_threading.py index 2d0dadd..4e983ce 100644 --- a/Lib/test/test_dummy_threading.py +++ b/Lib/test/test_dummy_threading.py @@ -1,4 +1,4 @@ -from test import test_support +from test import support import unittest import dummy_threading as _threading import time @@ -15,20 +15,20 @@ class DummyThreadingTestCase(unittest.TestCase): # module. #delay = random.random() * 2 delay = 0 - if test_support.verbose: + if support.verbose: print('task', self.getName(), 'will run for', delay, 'sec') sema.acquire() mutex.acquire() running += 1 - if test_support.verbose: + if support.verbose: print(running, 'tasks are running') mutex.release() time.sleep(delay) - if test_support.verbose: + if support.verbose: print('task', self.getName(), 'done') mutex.acquire() running -= 1 - if test_support.verbose: + if support.verbose: print(self.getName(), 'is finished.', running, 'tasks are running') mutex.release() sema.release() @@ -49,15 +49,15 @@ class DummyThreadingTestCase(unittest.TestCase): self.threads.append(t) t.start() - if test_support.verbose: + if support.verbose: print('waiting for all tasks to complete') for t in self.threads: t.join() - if test_support.verbose: + if support.verbose: print('all tasks done') def test_main(): - test_support.run_unittest(DummyThreadingTestCase) + support.run_unittest(DummyThreadingTestCase) if __name__ == '__main__': diff --git a/Lib/test/test_email.py b/Lib/test/test_email.py index e12cbd3..f0a18e7 100644 --- a/Lib/test/test_email.py +++ b/Lib/test/test_email.py @@ -3,10 +3,10 @@ # The specific tests now live in Lib/email/test from email.test.test_email import suite -from test import test_support +from test import support def test_main(): - test_support.run_unittest(suite()) + support.run_unittest(suite()) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_enumerate.py b/Lib/test/test_enumerate.py index f5c5689..cdb9e7e 100644 --- a/Lib/test/test_enumerate.py +++ b/Lib/test/test_enumerate.py @@ -1,7 +1,7 @@ import unittest import sys -from test import test_support +from test import support class G: 'Sequence using __getitem__' @@ -215,14 +215,14 @@ class TestLongStart(EnumerateTestCase): def test_main(verbose=None): testclasses = (EnumerateTestCase, SubclassTestCase, TestEmpty, TestBig, TestReversed) - test_support.run_unittest(*testclasses) + support.run_unittest(*testclasses) # verify reference counting import sys if verbose and hasattr(sys, "gettotalrefcount"): counts = [None] * 5 for i in range(len(counts)): - test_support.run_unittest(*testclasses) + support.run_unittest(*testclasses) counts[i] = sys.gettotalrefcount() print(counts) diff --git a/Lib/test/test_eof.py b/Lib/test/test_eof.py index 91fd845..4e37560 100644 --- a/Lib/test/test_eof.py +++ b/Lib/test/test_eof.py @@ -2,7 +2,7 @@ """test script for a few new invalid token catches""" import unittest -from test import test_support +from test import support class EOFTestCase(unittest.TestCase): def test_EOFC(self): @@ -13,7 +13,7 @@ class EOFTestCase(unittest.TestCase): except SyntaxError as msg: self.assertEqual(str(msg), expect) else: - raise test_support.TestFailed + raise support.TestFailed def test_EOFS(self): expect = ("EOF while scanning triple-quoted string literal " @@ -23,10 +23,10 @@ class EOFTestCase(unittest.TestCase): except SyntaxError as msg: self.assertEqual(str(msg), expect) else: - raise test_support.TestFailed + raise support.TestFailed def test_main(): - test_support.run_unittest(EOFTestCase) + support.run_unittest(EOFTestCase) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_epoll.py b/Lib/test/test_epoll.py index 1e30d61..b1ca322 100644 --- a/Lib/test/test_epoll.py +++ b/Lib/test/test_epoll.py @@ -29,15 +29,15 @@ import select import tempfile import unittest -from test import test_support +from test import support if not hasattr(select, "epoll"): - raise test_support.TestSkipped("test works only on Linux 2.6") + raise support.TestSkipped("test works only on Linux 2.6") try: select.epoll() except IOError as e: if e.errno == errno.ENOSYS: - raise test_support.TestSkipped("kernel doesn't support epoll()") + raise support.TestSkipped("kernel doesn't support epoll()") class TestEPoll(unittest.TestCase): @@ -189,7 +189,7 @@ class TestEPoll(unittest.TestCase): ep.unregister(fd) def test_main(): - test_support.run_unittest(TestEPoll) + support.run_unittest(TestEPoll) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_errno.py b/Lib/test/test_errno.py index 3077191..28425e2 100755 --- a/Lib/test/test_errno.py +++ b/Lib/test/test_errno.py @@ -4,7 +4,7 @@ """ import errno -from test import test_support +from test import support import unittest std_c_errors = frozenset(['EDOM', 'ERANGE']) @@ -33,7 +33,7 @@ class ErrorcodeTests(unittest.TestCase): def test_main(): - test_support.run_unittest(ErrnoAttributeTests, ErrorcodeTests) + support.run_unittest(ErrnoAttributeTests, ErrorcodeTests) if __name__ == '__main__': diff --git a/Lib/test/test_exception_variations.py b/Lib/test/test_exception_variations.py index 5bcb8fc..11f5e5c 100644 --- a/Lib/test/test_exception_variations.py +++ b/Lib/test/test_exception_variations.py @@ -1,5 +1,5 @@ -from test.test_support import run_unittest +from test.support import run_unittest import unittest class ExceptionTestCase(unittest.TestCase): diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index 0574356..619b7e3 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -6,7 +6,7 @@ import unittest import pickle import weakref -from test.test_support import TESTFN, unlink, run_unittest +from test.support import TESTFN, unlink, run_unittest # XXX This is not really enough, each *operation* should be tested! diff --git a/Lib/test/test_extcall.py b/Lib/test/test_extcall.py index 3cf7ac2..7ed0e2e 100644 --- a/Lib/test/test_extcall.py +++ b/Lib/test/test_extcall.py @@ -11,10 +11,10 @@ We're defining four helper functions ... print(a, b) >>> def f(*a, **k): - ... print(a, test_support.sortdict(k)) + ... print(a, support.sortdict(k)) >>> def g(x, *y, **z): - ... print(x, y, test_support.sortdict(z)) + ... print(x, y, support.sortdict(z)) >>> def h(j=1, a=2, h=3): ... print(j, a, h) @@ -245,11 +245,11 @@ TypeError if te dictionary is not empty """ -from test import test_support +from test import support def test_main(): from test import test_extcall # self import - test_support.run_doctest(test_extcall, True) + support.run_doctest(test_extcall, True) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_fcntl.py b/Lib/test/test_fcntl.py index 1369612..afb511c 100755 --- a/Lib/test/test_fcntl.py +++ b/Lib/test/test_fcntl.py @@ -8,7 +8,7 @@ import os import struct import sys import unittest -from test.test_support import verbose, TESTFN, unlink, run_unittest +from test.support import verbose, TESTFN, unlink, run_unittest # TODO - Write tests for flock() and lockf(). diff --git a/Lib/test/test_file.py b/Lib/test/test_file.py index 5102de3..ff4996a 100644 --- a/Lib/test/test_file.py +++ b/Lib/test/test_file.py @@ -4,7 +4,7 @@ import unittest from array import array from weakref import proxy -from test.test_support import TESTFN, findfile, run_unittest +from test.support import TESTFN, findfile, run_unittest from collections import UserList class AutoFileTests(unittest.TestCase): diff --git a/Lib/test/test_filecmp.py b/Lib/test/test_filecmp.py index 53b949d..22f0be7 100644 --- a/Lib/test/test_filecmp.py +++ b/Lib/test/test_filecmp.py @@ -1,13 +1,13 @@ import os, filecmp, shutil, tempfile, shutil import unittest -from test import test_support +from test import support class FileCompareTestCase(unittest.TestCase): def setUp(self): - self.name = test_support.TESTFN - self.name_same = test_support.TESTFN + '-same' - self.name_diff = test_support.TESTFN + '-diff' + self.name = support.TESTFN + self.name_same = support.TESTFN + '-same' + self.name_diff = support.TESTFN + '-diff' data = 'Contents of file go here.\n' for name in [self.name, self.name_same, self.name_diff]: output = open(name, 'w') @@ -128,7 +128,7 @@ class DirCompareTestCase(unittest.TestCase): def test_main(): - test_support.run_unittest(FileCompareTestCase, DirCompareTestCase) + support.run_unittest(FileCompareTestCase, DirCompareTestCase) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_fileinput.py b/Lib/test/test_fileinput.py index 76a41a6..a4d59e1 100644 --- a/Lib/test/test_fileinput.py +++ b/Lib/test/test_fileinput.py @@ -4,8 +4,8 @@ Nick Mathewson ''' import unittest -from test.test_support import verbose, TESTFN, run_unittest -from test.test_support import unlink as safe_unlink +from test.support import verbose, TESTFN, run_unittest +from test.support import unlink as safe_unlink import sys, re from io import StringIO from fileinput import FileInput, hook_encoded diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py index 2f9c23f..c94ceaf 100644 --- a/Lib/test/test_fileio.py +++ b/Lib/test/test_fileio.py @@ -6,7 +6,7 @@ import unittest from array import array from weakref import proxy -from test.test_support import TESTFN, findfile, run_unittest +from test.support import TESTFN, findfile, run_unittest from collections import UserList import _fileio diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py index 5653c16..d17400c 100644 --- a/Lib/test/test_float.py +++ b/Lib/test/test_float.py @@ -1,7 +1,7 @@ import unittest, struct import os -from test import test_support +from test import support import math from math import isinf, isnan import operator @@ -28,7 +28,7 @@ class GeneralFloatCases(unittest.TestCase): # Implementation limitation in PyFloat_FromString() self.assertRaises(ValueError, float, unicode("1"*10000)) - @test_support.run_with_locale('LC_NUMERIC', 'fr_FR', 'de_DE') + @support.run_with_locale('LC_NUMERIC', 'fr_FR', 'de_DE') def test_float_with_comma(self): # set locale to something that doesn't use '.' for the decimal point # float must not accept the locale specific decimal point but @@ -361,7 +361,7 @@ class InfNanTest(unittest.TestCase): def test_main(): - test_support.run_unittest( + support.run_unittest( FormatFunctionsTestCase, UnknownFormatTestCase, IEEEFormatTestCase, diff --git a/Lib/test/test_fnmatch.py b/Lib/test/test_fnmatch.py index 9abcbd6..c593704 100644 --- a/Lib/test/test_fnmatch.py +++ b/Lib/test/test_fnmatch.py @@ -1,6 +1,6 @@ """Test cases for the fnmatch module.""" -from test import test_support +from test import support import unittest from fnmatch import fnmatch, fnmatchcase @@ -39,7 +39,7 @@ class FnmatchTestCase(unittest.TestCase): def test_main(): - test_support.run_unittest(FnmatchTestCase) + support.run_unittest(FnmatchTestCase) if __name__ == "__main__": diff --git a/Lib/test/test_fork1.py b/Lib/test/test_fork1.py index 221a14d..e6d9eed 100644 --- a/Lib/test/test_fork1.py +++ b/Lib/test/test_fork1.py @@ -4,7 +4,7 @@ import os import time from test.fork_wait import ForkWait -from test.test_support import TestSkipped, run_unittest, reap_children +from test.support import TestSkipped, run_unittest, reap_children try: os.fork diff --git a/Lib/test/test_format.py b/Lib/test/test_format.py index cbb7be8..fb91475 100644 --- a/Lib/test/test_format.py +++ b/Lib/test/test_format.py @@ -1,9 +1,9 @@ -from test.test_support import verbose, TestFailed +from test.support import verbose, TestFailed import sys -import test.test_support as test_support +import test.support as support import unittest -maxsize = test_support.MAX_Py_ssize_t +maxsize = support.MAX_Py_ssize_t # test string formatting operator (I am not sure if this is being tested # elsewhere but, surely, some of the given cases are *not* tested because @@ -256,7 +256,7 @@ class FormatTest(unittest.TestCase): raise TestFailed('"%*d"%(maxsize, -127) should fail') def test_main(): - test_support.run_unittest(FormatTest) + support.run_unittest(FormatTest) if __name__ == "__main__": diff --git a/Lib/test/test_fractions.py b/Lib/test/test_fractions.py index 21c1761..d06c206 100644 --- a/Lib/test/test_fractions.py +++ b/Lib/test/test_fractions.py @@ -1,7 +1,7 @@ """Tests for Lib/fractions.py.""" from decimal import Decimal -from test.test_support import run_unittest +from test.support import run_unittest import math import operator import fractions diff --git a/Lib/test/test_frozen.py b/Lib/test/test_frozen.py index de45b23..545941b 100644 --- a/Lib/test/test_frozen.py +++ b/Lib/test/test_frozen.py @@ -1,6 +1,6 @@ # Test the frozen module defined in frozen.c. -from test.test_support import captured_stdout, run_unittest +from test.support import captured_stdout, run_unittest import unittest import sys, os diff --git a/Lib/test/test_ftplib.py b/Lib/test/test_ftplib.py index 0204c6f..b91588a 100644 --- a/Lib/test/test_ftplib.py +++ b/Lib/test/test_ftplib.py @@ -4,9 +4,9 @@ import ftplib import time from unittest import TestCase -from test import test_support +from test import support -HOST = test_support.HOST +HOST = support.HOST # This function sets the evt 3 times: # 1) when the connection is ready to be accepted. @@ -37,7 +37,7 @@ class GeneralTests(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) threading.Thread(target=server, args=(self.evt,self.sock)).start() # Wait for the server to be ready. self.evt.wait() @@ -106,7 +106,7 @@ class GeneralTests(TestCase): def test_main(verbose=None): - test_support.run_unittest(GeneralTests) + support.run_unittest(GeneralTests) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_funcattrs.py b/Lib/test/test_funcattrs.py index 7385f96..5e9f7d3 100644 --- a/Lib/test/test_funcattrs.py +++ b/Lib/test/test_funcattrs.py @@ -1,4 +1,4 @@ -from test import test_support +from test import support import types import unittest @@ -225,7 +225,7 @@ class FunctionDocstringTest(FuncAttrsTest): self.assertEqual(self.b.__doc__, None) def test_main(): - test_support.run_unittest(FunctionPropertiesTest, ImplicitReferencesTest, + support.run_unittest(FunctionPropertiesTest, ImplicitReferencesTest, ArbitraryFunctionAttrTest, FunctionDictsTest, FunctionDocstringTest) diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py index a1e5d13..84e974a8 100644 --- a/Lib/test/test_functools.py +++ b/Lib/test/test_functools.py @@ -1,6 +1,6 @@ import functools import unittest -from test import test_support +from test import support from weakref import proxy @staticmethod @@ -347,14 +347,14 @@ def test_main(verbose=None): TestWraps, TestReduce ) - test_support.run_unittest(*test_classes) + support.run_unittest(*test_classes) # 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_future.py b/Lib/test/test_future.py index 1437489..494f539 100644 --- a/Lib/test/test_future.py +++ b/Lib/test/test_future.py @@ -1,7 +1,7 @@ # Test various flavors of legal and illegal future statements import unittest -from test import test_support +from test import support import re rx = re.compile('\((\S+).py, line (\d+)') @@ -13,17 +13,17 @@ def get_error_location(msg): class FutureTest(unittest.TestCase): def test_future1(self): - test_support.unload('test_future1') + support.unload('test_future1') from test import test_future1 self.assertEqual(test_future1.result, 6) def test_future2(self): - test_support.unload('test_future2') + support.unload('test_future2') from test import test_future2 self.assertEqual(test_future2.result, 6) def test_future3(self): - test_support.unload('test_future3') + support.unload('test_future3') from test import test_future3 def test_badfuture3(self): @@ -104,7 +104,7 @@ class FutureTest(unittest.TestCase): def test_main(): - test_support.run_unittest(FutureTest) + support.run_unittest(FutureTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_future3.py b/Lib/test/test_future3.py index ed23567..b1552a5 100644 --- a/Lib/test/test_future3.py +++ b/Lib/test/test_future3.py @@ -2,7 +2,7 @@ from __future__ import nested_scopes from __future__ import division import unittest -from test import test_support +from test import support x = 2 def nester(): @@ -24,7 +24,7 @@ class TestFuture(unittest.TestCase): self.assertEqual(nester(), 3) def test_main(): - test_support.run_unittest(TestFuture) + support.run_unittest(TestFuture) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_future4.py b/Lib/test/test_future4.py index 8ada489..c32f27f 100644 --- a/Lib/test/test_future4.py +++ b/Lib/test/test_future4.py @@ -1,7 +1,7 @@ from __future__ import unicode_literals import unittest -from test import test_support +from test import support def test_main(): pass diff --git a/Lib/test/test_gc.py b/Lib/test/test_gc.py index 9d5e0ea..414e17a 100644 --- a/Lib/test/test_gc.py +++ b/Lib/test/test_gc.py @@ -1,5 +1,5 @@ import unittest -from test.test_support import verbose, run_unittest +from test.support import verbose, run_unittest import sys import gc import weakref diff --git a/Lib/test/test_gdbm.py b/Lib/test/test_gdbm.py index 17a7f63..42cb136 100755 --- a/Lib/test/test_gdbm.py +++ b/Lib/test/test_gdbm.py @@ -1,7 +1,7 @@ import gdbm import unittest import os -from test.test_support import verbose, TESTFN, run_unittest, unlink +from test.support import verbose, TESTFN, run_unittest, unlink filename = TESTFN diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py index 56f23db..8f2da7d 100644 --- a/Lib/test/test_generators.py +++ b/Lib/test/test_generators.py @@ -1885,8 +1885,8 @@ __test__ = {"tut": tutorial_tests, # Note that doctest and regrtest both look in sys.argv for a "-v" argument, # so this works as expected in both ways of running regrtest. def test_main(verbose=None): - from test import test_support, test_generators - test_support.run_doctest(test_generators, verbose) + from test import support, test_generators + support.run_doctest(test_generators, verbose) # This part isn't needed for regrtest, but for running the test directly. if __name__ == "__main__": diff --git a/Lib/test/test_genericpath.py b/Lib/test/test_genericpath.py index d912714..9d0baeb 100644 --- a/Lib/test/test_genericpath.py +++ b/Lib/test/test_genericpath.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support import os import genericpath @@ -27,114 +27,114 @@ class AllCommonTest(unittest.TestCase): ) def test_getsize(self): - f = open(test_support.TESTFN, "wb") + f = open(support.TESTFN, "wb") try: f.write(b"foo") f.close() - self.assertEqual(genericpath.getsize(test_support.TESTFN), 3) + self.assertEqual(genericpath.getsize(support.TESTFN), 3) finally: if not f.closed: f.close() - os.remove(test_support.TESTFN) + os.remove(support.TESTFN) def test_time(self): - f = open(test_support.TESTFN, "wb") + f = open(support.TESTFN, "wb") try: f.write(b"foo") f.close() - f = open(test_support.TESTFN, "ab") + f = open(support.TESTFN, "ab") f.write(b"bar") f.close() - f = open(test_support.TESTFN, "rb") + f = open(support.TESTFN, "rb") d = f.read() f.close() self.assertEqual(d, b"foobar") self.assert_( - genericpath.getctime(test_support.TESTFN) <= - genericpath.getmtime(test_support.TESTFN) + genericpath.getctime(support.TESTFN) <= + genericpath.getmtime(support.TESTFN) ) finally: if not f.closed: f.close() - os.remove(test_support.TESTFN) + os.remove(support.TESTFN) def test_exists(self): - self.assertIs(genericpath.exists(test_support.TESTFN), False) - f = open(test_support.TESTFN, "wb") + self.assertIs(genericpath.exists(support.TESTFN), False) + f = open(support.TESTFN, "wb") try: f.write(b"foo") f.close() - self.assertIs(genericpath.exists(test_support.TESTFN), True) + self.assertIs(genericpath.exists(support.TESTFN), True) finally: if not f.close(): f.close() try: - os.remove(test_support.TESTFN) + os.remove(support.TESTFN) except os.error: pass self.assertRaises(TypeError, genericpath.exists) def test_isdir(self): - self.assertIs(genericpath.isdir(test_support.TESTFN), False) - f = open(test_support.TESTFN, "wb") + self.assertIs(genericpath.isdir(support.TESTFN), False) + f = open(support.TESTFN, "wb") try: f.write(b"foo") f.close() - self.assertIs(genericpath.isdir(test_support.TESTFN), False) - os.remove(test_support.TESTFN) - os.mkdir(test_support.TESTFN) - self.assertIs(genericpath.isdir(test_support.TESTFN), True) - os.rmdir(test_support.TESTFN) + self.assertIs(genericpath.isdir(support.TESTFN), False) + os.remove(support.TESTFN) + os.mkdir(support.TESTFN) + self.assertIs(genericpath.isdir(support.TESTFN), True) + os.rmdir(support.TESTFN) finally: if not f.close(): f.close() try: - os.remove(test_support.TESTFN) + os.remove(support.TESTFN) except os.error: pass try: - os.rmdir(test_support.TESTFN) + os.rmdir(support.TESTFN) except os.error: pass self.assertRaises(TypeError, genericpath.isdir) def test_isfile(self): - self.assertIs(genericpath.isfile(test_support.TESTFN), False) - f = open(test_support.TESTFN, "wb") + self.assertIs(genericpath.isfile(support.TESTFN), False) + f = open(support.TESTFN, "wb") try: f.write(b"foo") f.close() - self.assertIs(genericpath.isfile(test_support.TESTFN), True) - os.remove(test_support.TESTFN) - os.mkdir(test_support.TESTFN) - self.assertIs(genericpath.isfile(test_support.TESTFN), False) - os.rmdir(test_support.TESTFN) + self.assertIs(genericpath.isfile(support.TESTFN), True) + os.remove(support.TESTFN) + os.mkdir(support.TESTFN) + self.assertIs(genericpath.isfile(support.TESTFN), False) + os.rmdir(support.TESTFN) finally: if not f.close(): f.close() try: - os.remove(test_support.TESTFN) + os.remove(support.TESTFN) except os.error: pass try: - os.rmdir(test_support.TESTFN) + os.rmdir(support.TESTFN) except os.error: pass self.assertRaises(TypeError, genericpath.isdir) def test_samefile(self): - f = open(test_support.TESTFN + "1", "wb") + f = open(support.TESTFN + "1", "wb") try: f.write(b"foo") f.close() self.assertIs( genericpath.samefile( - test_support.TESTFN + "1", - test_support.TESTFN + "1" + support.TESTFN + "1", + support.TESTFN + "1" ), True ) @@ -142,24 +142,24 @@ class AllCommonTest(unittest.TestCase): # inode information and thus, that samefile() doesn't work if hasattr(os, "symlink"): os.symlink( - test_support.TESTFN + "1", - test_support.TESTFN + "2" + support.TESTFN + "1", + support.TESTFN + "2" ) self.assertIs( genericpath.samefile( - test_support.TESTFN + "1", - test_support.TESTFN + "2" + support.TESTFN + "1", + support.TESTFN + "2" ), True ) - os.remove(test_support.TESTFN + "2") - f = open(test_support.TESTFN + "2", "wb") + os.remove(support.TESTFN + "2") + f = open(support.TESTFN + "2", "wb") f.write(b"bar") f.close() self.assertIs( genericpath.samefile( - test_support.TESTFN + "1", - test_support.TESTFN + "2" + support.TESTFN + "1", + support.TESTFN + "2" ), False ) @@ -167,18 +167,18 @@ class AllCommonTest(unittest.TestCase): if not f.close(): f.close() try: - os.remove(test_support.TESTFN + "1") + os.remove(support.TESTFN + "1") except os.error: pass try: - os.remove(test_support.TESTFN + "2") + os.remove(support.TESTFN + "2") except os.error: pass self.assertRaises(TypeError, genericpath.samefile) def test_main(): - test_support.run_unittest(AllCommonTest) + support.run_unittest(AllCommonTest) if __name__=="__main__": test_main() diff --git a/Lib/test/test_genexps.py b/Lib/test/test_genexps.py index 593c1c5..61e9fe5 100644 --- a/Lib/test/test_genexps.py +++ b/Lib/test/test_genexps.py @@ -262,16 +262,16 @@ __test__ = {'doctests' : doctests} def test_main(verbose=None): import sys - from test import test_support + from test import support from test import test_genexps - test_support.run_doctest(test_genexps, verbose) + support.run_doctest(test_genexps, verbose) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in range(len(counts)): - test_support.run_doctest(test_genexps, verbose) + support.run_doctest(test_genexps, verbose) gc.collect() counts[i] = sys.gettotalrefcount() print(counts) diff --git a/Lib/test/test_getargs2.py b/Lib/test/test_getargs2.py index 69791e8..34d8ee0 100644 --- a/Lib/test/test_getargs2.py +++ b/Lib/test/test_getargs2.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support from _testcapi import getargs_keywords import warnings @@ -306,7 +306,7 @@ def test_main(): pass # PY_LONG_LONG not available else: tests.append(LongLong_TestCase) - test_support.run_unittest(*tests) + support.run_unittest(*tests) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_getopt.py b/Lib/test/test_getopt.py index 36d1688..de3325d 100644 --- a/Lib/test/test_getopt.py +++ b/Lib/test/test_getopt.py @@ -1,7 +1,7 @@ # test_getopt.py # David Goodger 2000-08-19 -from test.test_support import verbose, run_doctest, run_unittest +from test.support import verbose, run_doctest, run_unittest import unittest import getopt diff --git a/Lib/test/test_gettext.py b/Lib/test/test_gettext.py index a875272..73c9c1c 100644 --- a/Lib/test/test_gettext.py +++ b/Lib/test/test_gettext.py @@ -4,7 +4,7 @@ import shutil import gettext import unittest -from test import test_support +from test import support # TODO: @@ -338,7 +338,7 @@ class WeirdMetadataTest(GettextBaseTest): def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_glob.py b/Lib/test/test_glob.py index a628e6e..adaea18 100644 --- a/Lib/test/test_glob.py +++ b/Lib/test/test_glob.py @@ -1,5 +1,5 @@ import unittest -from test.test_support import run_unittest, TESTFN +from test.support import run_unittest, TESTFN import glob import os import shutil diff --git a/Lib/test/test_global.py b/Lib/test/test_global.py index 2a58a10..823f2c5 100644 --- a/Lib/test/test_global.py +++ b/Lib/test/test_global.py @@ -1,6 +1,6 @@ """Verify that warnings are issued for global statements following use.""" -from test.test_support import run_unittest, check_syntax_error +from test.support import run_unittest, check_syntax_error import unittest import warnings diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py index 94b7b31..1a34ff8 100644 --- a/Lib/test/test_grammar.py +++ b/Lib/test/test_grammar.py @@ -8,7 +8,7 @@ # regression test, the filterwarnings() call has been added to # regrtest.py. -from test.test_support import run_unittest, check_syntax_error +from test.support import run_unittest, check_syntax_error import unittest import sys # testing import * diff --git a/Lib/test/test_grp.py b/Lib/test/test_grp.py index fb607f0..5acda52 100755 --- a/Lib/test/test_grp.py +++ b/Lib/test/test_grp.py @@ -2,7 +2,7 @@ import grp import unittest -from test import test_support +from test import support class GroupDatabaseTestCase(unittest.TestCase): @@ -86,7 +86,7 @@ class GroupDatabaseTestCase(unittest.TestCase): self.assertRaises(KeyError, grp.getgrgid, fakegid) def test_main(): - test_support.run_unittest(GroupDatabaseTestCase) + support.run_unittest(GroupDatabaseTestCase) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_gzip.py b/Lib/test/test_gzip.py index 0010112..c26035b 100644 --- a/Lib/test/test_gzip.py +++ b/Lib/test/test_gzip.py @@ -3,7 +3,7 @@ """ import unittest -from test import test_support +from test import support import os import gzip @@ -22,13 +22,13 @@ data2 = b"""/* zlibmodule.c -- gzip-compatible data compression */ class TestGzip(unittest.TestCase): - filename = test_support.TESTFN + filename = support.TESTFN def setUp (self): - test_support.unlink(self.filename) + support.unlink(self.filename) def tearDown (self): - test_support.unlink(self.filename) + support.unlink(self.filename) def test_write (self): @@ -158,7 +158,7 @@ class TestGzip(unittest.TestCase): f.close() def test_main(verbose=None): - test_support.run_unittest(TestGzip) + support.run_unittest(TestGzip) if __name__ == "__main__": test_main(verbose=True) diff --git a/Lib/test/test_hash.py b/Lib/test/test_hash.py index a0364f2..fb1699a 100644 --- a/Lib/test/test_hash.py +++ b/Lib/test/test_hash.py @@ -3,7 +3,7 @@ # import unittest -from test import test_support +from test import support class HashEqualityTestCase(unittest.TestCase): @@ -38,7 +38,7 @@ class HashEqualityTestCase(unittest.TestCase): def test_main(): - test_support.run_unittest(HashEqualityTestCase) + support.run_unittest(HashEqualityTestCase) if __name__ == "__main__": diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py index 399e50b..912b133 100644 --- a/Lib/test/test_hashlib.py +++ b/Lib/test/test_hashlib.py @@ -8,7 +8,7 @@ import hashlib import unittest -from test import test_support +from test import support def hexstr(s): @@ -186,7 +186,7 @@ class HashLibTestCase(unittest.TestCase): def test_main(): - test_support.run_unittest(HashLibTestCase) + support.run_unittest(HashLibTestCase) if __name__ == "__main__": diff --git a/Lib/test/test_heapq.py b/Lib/test/test_heapq.py index 24d2992..e41abf0 100644 --- a/Lib/test/test_heapq.py +++ b/Lib/test/test_heapq.py @@ -2,7 +2,7 @@ import random import unittest -from test import test_support +from test import support import sys # We do a bit of trickery here to be able to test both the C implementation @@ -353,14 +353,14 @@ def test_main(verbose=None): from types import BuiltinFunctionType test_classes = [TestHeapPython, TestHeapC, TestErrorHandling] - test_support.run_unittest(*test_classes) + support.run_unittest(*test_classes) # 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_hmac.py b/Lib/test/test_hmac.py index 537f298..43953cf 100644 --- a/Lib/test/test_hmac.py +++ b/Lib/test/test_hmac.py @@ -2,7 +2,7 @@ import hmac import hashlib import unittest import warnings -from test import test_support +from test import support class TestVectorsTestCase(unittest.TestCase): @@ -211,7 +211,7 @@ class TestVectorsTestCase(unittest.TestCase): def digest(self): return self._x.digest() - with test_support.catch_warning(): + with support.catch_warning(): warnings.simplefilter('error', RuntimeWarning) try: hmac.HMAC(b'a', b'b', digestmod=MockCrazyHash) @@ -309,7 +309,7 @@ class CopyTestCase(unittest.TestCase): "Hexdigest of copy doesn't match original hexdigest.") def test_main(): - test_support.run_unittest( + support.run_unittest( TestVectorsTestCase, ConstructorTestCase, SanityTestCase, diff --git a/Lib/test/test_htmllib.py b/Lib/test/test_htmllib.py index a20f43b..61f3a13 100644 --- a/Lib/test/test_htmllib.py +++ b/Lib/test/test_htmllib.py @@ -2,7 +2,7 @@ import formatter import htmllib import unittest -from test import test_support +from test import support class AnchorCollector(htmllib.HTMLParser): @@ -62,7 +62,7 @@ class HTMLParserTestCase(unittest.TestCase): ]) def test_main(): - test_support.run_unittest(HTMLParserTestCase) + support.run_unittest(HTMLParserTestCase) if __name__ == "__main__": diff --git a/Lib/test/test_htmlparser.py b/Lib/test/test_htmlparser.py index a4f2c34..8691cbf 100755 --- a/Lib/test/test_htmlparser.py +++ b/Lib/test/test_htmlparser.py @@ -3,7 +3,7 @@ import HTMLParser import pprint import unittest -from test import test_support +from test import support class EventCollector(HTMLParser.HTMLParser): @@ -315,7 +315,7 @@ DOCTYPE html [ def test_main(): - test_support.run_unittest(HTMLParserTestCase) + support.run_unittest(HTMLParserTestCase) if __name__ == "__main__": diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py index f0e551f..7a77cff 100644 --- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@ -4,9 +4,9 @@ import socket from unittest import TestCase -from test import test_support +from test import support -HOST = test_support.HOST +HOST = support.HOST class FakeSocket: def __init__(self, text, fileclass=io.BytesIO): @@ -206,7 +206,7 @@ class TimeoutTest(TestCase): def setUp(self): self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - TimeoutTest.PORT = test_support.bind_port(self.serv) + TimeoutTest.PORT = support.bind_port(self.serv) self.serv.listen(5) def tearDown(self): @@ -252,7 +252,7 @@ class HTTPSTimeoutTest(TestCase): self.assertEqual(h.timeout, 30) def test_main(verbose=None): - test_support.run_unittest(HeaderTests, OfflineTest, BasicTest, TimeoutTest, + support.run_unittest(HeaderTests, OfflineTest, BasicTest, TimeoutTest, HTTPSTimeoutTest) if __name__ == '__main__': diff --git a/Lib/test/test_imaplib.py b/Lib/test/test_imaplib.py index ce0e075..2105fc2 100644 --- a/Lib/test/test_imaplib.py +++ b/Lib/test/test_imaplib.py @@ -1,7 +1,7 @@ import imaplib import time -from test import test_support +from test import support import unittest @@ -18,7 +18,7 @@ class TestImaplib(unittest.TestCase): def test_main(): - test_support.run_unittest(TestImaplib) + support.run_unittest(TestImaplib) if __name__ == "__main__": diff --git a/Lib/test/test_imp.py b/Lib/test/test_imp.py index 13a3bfd..e2b9e9a 100644 --- a/Lib/test/test_imp.py +++ b/Lib/test/test_imp.py @@ -1,6 +1,6 @@ import imp import unittest -from test import test_support +from test import support class LockTests(unittest.TestCase): @@ -69,7 +69,7 @@ class ImportTests(unittest.TestCase): def test_main(): - test_support.run_unittest( + support.run_unittest( LockTests, ImportTests, ) diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py index 1c9dd3a..81e221d 100644 --- a/Lib/test/test_import.py +++ b/Lib/test/test_import.py @@ -1,4 +1,4 @@ -from test.test_support import TESTFN, run_unittest, catch_warning +from test.support import TESTFN, run_unittest, catch_warning import unittest import os @@ -8,7 +8,7 @@ import sys import py_compile import warnings import imp -from test.test_support import unlink, TESTFN, unload +from test.support import unlink, TESTFN, unload def remove_files(name): @@ -146,13 +146,13 @@ class ImportTest(unittest.TestCase): def test_import_name_binding(self): # import x.y.z binds x in the current namespace import test as x - import test.test_support + import test.support self.assert_(x is test, x.__name__) - self.assert_(hasattr(test.test_support, "__file__")) + self.assert_(hasattr(test.support, "__file__")) # import x.y.z as w binds z as w - import test.test_support as y - self.assert_(y is test.test_support, y.__name__) + import test.support as y + self.assert_(y is test.support, y.__name__) def test_import_initless_directory_warning(self): with catch_warning(): diff --git a/Lib/test/test_importhooks.py b/Lib/test/test_importhooks.py index 3108bd6..eaf213d 100644 --- a/Lib/test/test_importhooks.py +++ b/Lib/test/test_importhooks.py @@ -2,7 +2,7 @@ import sys import imp import os import unittest -from test import test_support +from test import support test_src = """\ @@ -265,7 +265,7 @@ class ImportHooksTestCase(ImportHooksBaseTestCase): pass def test_main(): - test_support.run_unittest(ImportHooksTestCase) + support.run_unittest(ImportHooksTestCase) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_index.py b/Lib/test/test_index.py index 71cfb15..31609c3 100644 --- a/Lib/test/test_index.py +++ b/Lib/test/test_index.py @@ -1,7 +1,7 @@ import unittest -from test import test_support +from test import support import operator -maxsize = test_support.MAX_Py_ssize_t +maxsize = support.MAX_Py_ssize_t minsize = -maxsize-1 class oldstyle: @@ -193,7 +193,7 @@ class OverflowTestCase(unittest.TestCase): def test_main(): - test_support.run_unittest( + support.run_unittest( BaseTestCase, ListTestCase, TupleTestCase, diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py index c62fa55..55fae20 100644 --- a/Lib/test/test_inspect.py +++ b/Lib/test/test_inspect.py @@ -6,7 +6,7 @@ import datetime import collections from os.path import normcase -from test.test_support import TESTFN, run_unittest +from test.support import TESTFN, run_unittest from test import inspect_fodder as mod from test import inspect_fodder2 as mod2 diff --git a/Lib/test/test_int.py b/Lib/test/test_int.py index 91d5273..3462540 100644 --- a/Lib/test/test_int.py +++ b/Lib/test/test_int.py @@ -1,7 +1,7 @@ import sys import unittest -from test.test_support import run_unittest +from test.support import run_unittest L = [ ('0', 0), diff --git a/Lib/test/test_int_literal.py b/Lib/test/test_int_literal.py index 9bd0c41..1d578a7 100644 --- a/Lib/test/test_int_literal.py +++ b/Lib/test/test_int_literal.py @@ -4,7 +4,7 @@ This is complex because of changes due to PEP 237. """ import unittest -from test import test_support +from test import support class TestHexOctBin(unittest.TestCase): @@ -141,7 +141,7 @@ class TestHexOctBin(unittest.TestCase): self.assertEqual(-0b1111111111111111111111111111111111111111111111111111111111111111, -18446744073709551615) def test_main(): - test_support.run_unittest(TestHexOctBin) + support.run_unittest(TestHexOctBin) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index fa3a8bb..320c7c3 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -6,7 +6,7 @@ import time import array import unittest from itertools import chain -from test import test_support +from test import support import codecs import io # The module under test @@ -80,10 +80,10 @@ class MockNonBlockWriterIO(io.RawIOBase): class IOTest(unittest.TestCase): def setUp(self): - test_support.unlink(test_support.TESTFN) + support.unlink(support.TESTFN) def tearDown(self): - test_support.unlink(test_support.TESTFN) + support.unlink(support.TESTFN) def write_ops(self, f): self.assertEqual(f.write(b"blah."), 5) @@ -149,13 +149,13 @@ class IOTest(unittest.TestCase): self.assertEqual(f.read(2), b"x") def test_raw_file_io(self): - f = io.open(test_support.TESTFN, "wb", buffering=0) + f = io.open(support.TESTFN, "wb", buffering=0) self.assertEqual(f.readable(), False) self.assertEqual(f.writable(), True) self.assertEqual(f.seekable(), True) self.write_ops(f) f.close() - f = io.open(test_support.TESTFN, "rb", buffering=0) + f = io.open(support.TESTFN, "rb", buffering=0) self.assertEqual(f.readable(), True) self.assertEqual(f.writable(), False) self.assertEqual(f.seekable(), True) @@ -163,13 +163,13 @@ class IOTest(unittest.TestCase): f.close() def test_buffered_file_io(self): - f = io.open(test_support.TESTFN, "wb") + f = io.open(support.TESTFN, "wb") self.assertEqual(f.readable(), False) self.assertEqual(f.writable(), True) self.assertEqual(f.seekable(), True) self.write_ops(f) f.close() - f = io.open(test_support.TESTFN, "rb") + f = io.open(support.TESTFN, "rb") self.assertEqual(f.readable(), True) self.assertEqual(f.writable(), False) self.assertEqual(f.seekable(), True) @@ -177,10 +177,10 @@ class IOTest(unittest.TestCase): f.close() def test_readline(self): - f = io.open(test_support.TESTFN, "wb") + f = io.open(support.TESTFN, "wb") f.write(b"abc\ndef\nxyzzy\nfoo") f.close() - f = io.open(test_support.TESTFN, "rb") + f = io.open(support.TESTFN, "rb") self.assertEqual(f.readline(), b"abc\n") self.assertEqual(f.readline(10), b"def\n") self.assertEqual(f.readline(2), b"xy") @@ -201,7 +201,7 @@ class IOTest(unittest.TestCase): # a long time to build the >2GB file and takes >2GB of disk space # therefore the resource must be enabled to run this test. if sys.platform[:3] == 'win' or sys.platform == 'darwin': - if not test_support.is_resource_enabled("largefile"): + if not support.is_resource_enabled("largefile"): print("\nTesting large file ops skipped on %s." % sys.platform, file=sys.stderr) print("It requires %d bytes and a long time." % self.LARGE, @@ -209,22 +209,22 @@ class IOTest(unittest.TestCase): print("Use 'regrtest.py -u largefile test_io' to run it.", file=sys.stderr) return - f = io.open(test_support.TESTFN, "w+b", 0) + f = io.open(support.TESTFN, "w+b", 0) self.large_file_ops(f) f.close() - f = io.open(test_support.TESTFN, "w+b") + f = io.open(support.TESTFN, "w+b") self.large_file_ops(f) f.close() def test_with_open(self): for bufsize in (0, 1, 100): f = None - with open(test_support.TESTFN, "wb", bufsize) as f: + with open(support.TESTFN, "wb", bufsize) as f: f.write(b"xxx") self.assertEqual(f.closed, True) f = None try: - with open(test_support.TESTFN, "wb", bufsize) as f: + with open(support.TESTFN, "wb", bufsize) as f: 1/0 except ZeroDivisionError: self.assertEqual(f.closed, True) @@ -243,31 +243,31 @@ class IOTest(unittest.TestCase): def flush(self): record.append(3) io.FileIO.flush(self) - f = MyFileIO(test_support.TESTFN, "w") + f = MyFileIO(support.TESTFN, "w") f.write("xxx") del f self.assertEqual(record, [1, 2, 3]) def test_close_flushes(self): - f = io.open(test_support.TESTFN, "wb") + f = io.open(support.TESTFN, "wb") f.write(b"xxx") f.close() - f = io.open(test_support.TESTFN, "rb") + f = io.open(support.TESTFN, "rb") self.assertEqual(f.read(), b"xxx") f.close() def test_array_writes(self): a = array.array('i', range(10)) n = len(memoryview(a)) - f = io.open(test_support.TESTFN, "wb", 0) + f = io.open(support.TESTFN, "wb", 0) self.assertEqual(f.write(a), n) f.close() - f = io.open(test_support.TESTFN, "wb") + f = io.open(support.TESTFN, "wb") self.assertEqual(f.write(a), n) f.close() def test_closefd(self): - self.assertRaises(ValueError, io.open, test_support.TESTFN, 'w', + self.assertRaises(ValueError, io.open, support.TESTFN, 'w', closefd=False) class MemorySeekTestMixin: @@ -638,10 +638,10 @@ class TextIOWrapperTest(unittest.TestCase): def setUp(self): self.testdata = b"AAA\r\nBBB\rCCC\r\nDDD\nEEE\r\n" self.normalized = b"AAA\nBBB\nCCC\nDDD\nEEE\n".decode("ascii") - test_support.unlink(test_support.TESTFN) + support.unlink(support.TESTFN) def tearDown(self): - test_support.unlink(test_support.TESTFN) + support.unlink(support.TESTFN) def testLineBuffering(self): r = io.BytesIO() @@ -818,11 +818,11 @@ class TextIOWrapperTest(unittest.TestCase): def testBasicIO(self): for chunksize in (1, 2, 3, 4, 5, 15, 16, 17, 31, 32, 33, 63, 64, 65): for enc in "ascii", "latin1", "utf8" :# , "utf-16-be", "utf-16-le": - f = io.open(test_support.TESTFN, "w+", encoding=enc) + f = io.open(support.TESTFN, "w+", encoding=enc) f._CHUNK_SIZE = chunksize self.assertEquals(f.write("abc"), 3) f.close() - f = io.open(test_support.TESTFN, "r+", encoding=enc) + f = io.open(support.TESTFN, "r+", encoding=enc) f._CHUNK_SIZE = chunksize self.assertEquals(f.tell(), 0) self.assertEquals(f.read(), "abc") @@ -865,7 +865,7 @@ class TextIOWrapperTest(unittest.TestCase): self.assertEquals(rlines, wlines) def testTelling(self): - f = io.open(test_support.TESTFN, "w+", encoding="utf8") + f = io.open(support.TESTFN, "w+", encoding="utf8") p0 = f.tell() f.write("\xff\n") p1 = f.tell() @@ -893,10 +893,10 @@ class TextIOWrapperTest(unittest.TestCase): u_suffix = "\u8888\n" suffix = bytes(u_suffix.encode("utf-8")) line = prefix + suffix - f = io.open(test_support.TESTFN, "wb") + f = io.open(support.TESTFN, "wb") f.write(line*2) f.close() - f = io.open(test_support.TESTFN, "r", encoding="utf-8") + f = io.open(support.TESTFN, "r", encoding="utf-8") s = f.read(prefix_size) self.assertEquals(s, str(prefix, "ascii")) self.assertEquals(f.tell(), prefix_size) @@ -905,10 +905,10 @@ class TextIOWrapperTest(unittest.TestCase): def testSeekingToo(self): # Regression test for a specific bug data = b'\xe0\xbf\xbf\n' - f = io.open(test_support.TESTFN, "wb") + f = io.open(support.TESTFN, "wb") f.write(data) f.close() - f = io.open(test_support.TESTFN, "r", encoding="utf-8") + f = io.open(support.TESTFN, "r", encoding="utf-8") f._CHUNK_SIZE # Just test that it exists f._CHUNK_SIZE = 2 f.readline() @@ -920,16 +920,16 @@ class TextIOWrapperTest(unittest.TestCase): def testSeekAndTellWithData(data, min_pos=0): """Tell/seek to various points within a data stream and ensure that the decoded data returned by read() is consistent.""" - f = io.open(test_support.TESTFN, 'wb') + f = io.open(support.TESTFN, 'wb') f.write(data) f.close() - f = io.open(test_support.TESTFN, encoding='test_decoder') + f = io.open(support.TESTFN, encoding='test_decoder') decoded = f.read() f.close() for i in range(min_pos, len(decoded) + 1): # seek positions for j in [1, 5, len(decoded) - i]: # read lengths - f = io.open(test_support.TESTFN, encoding='test_decoder') + f = io.open(support.TESTFN, encoding='test_decoder') self.assertEquals(f.read(i), decoded[:i]) cookie = f.tell() self.assertEquals(f.read(j), decoded[i:i + j]) @@ -985,7 +985,7 @@ class TextIOWrapperTest(unittest.TestCase): nchars = len(line) nbytes = len(line.encode(enc)) for chunk_size in (32, 64, 128, 256): - f = io.open(test_support.TESTFN, "w+", encoding=enc) + f = io.open(support.TESTFN, "w+", encoding=enc) f._CHUNK_SIZE = chunk_size t0 = timer() for i in range(nlines): @@ -1005,7 +1005,7 @@ class TextIOWrapperTest(unittest.TestCase): f.tell() t4 = timer() f.close() - if test_support.verbose: + if support.verbose: print("\nTiming test: %d lines of %d characters (%d bytes)" % (nlines, nchars, nbytes)) print("File chunk size: %6s" % f._CHUNK_SIZE) @@ -1162,7 +1162,7 @@ class MiscIOTest(unittest.TestCase): def test_main(): - test_support.run_unittest(IOTest, BytesIOTest, StringIOTest, + support.run_unittest(IOTest, BytesIOTest, StringIOTest, BufferedReaderTest, BufferedWriterTest, BufferedRWPairTest, BufferedRandomTest, StatefulIncrementalDecoderTest, diff --git a/Lib/test/test_ioctl.py b/Lib/test/test_ioctl.py index feea5bf..e9c1d0f 100644 --- a/Lib/test/test_ioctl.py +++ b/Lib/test/test_ioctl.py @@ -1,5 +1,5 @@ import unittest -from test.test_support import TestSkipped, run_unittest +from test.support import TestSkipped, run_unittest import os, struct try: import fcntl, termios diff --git a/Lib/test/test_isinstance.py b/Lib/test/test_isinstance.py index 1e29f4c..9482e75 100644 --- a/Lib/test/test_isinstance.py +++ b/Lib/test/test_isinstance.py @@ -3,7 +3,7 @@ # testing of error conditions uncovered when using extension types. import unittest -from test import test_support +from test import support import sys @@ -264,7 +264,7 @@ def blowstack(fxn, arg, compare_to): def test_main(): - test_support.run_unittest( + support.run_unittest( TestIsInstanceExceptions, TestIsSubclassExceptions, TestIsInstanceIsSubclass diff --git a/Lib/test/test_iter.py b/Lib/test/test_iter.py index d861dcd..eba9728 100644 --- a/Lib/test/test_iter.py +++ b/Lib/test/test_iter.py @@ -1,7 +1,7 @@ # Test iterators. import unittest -from test.test_support import run_unittest, TESTFN, unlink +from test.support import run_unittest, TESTFN, unlink # Test result of triple loop (too big to inline) TRIPLETS = [(0, 0, 0), (0, 0, 1), (0, 0, 2), diff --git a/Lib/test/test_iterlen.py b/Lib/test/test_iterlen.py index 46aefaa..72e92a5 100644 --- a/Lib/test/test_iterlen.py +++ b/Lib/test/test_iterlen.py @@ -42,7 +42,7 @@ enumerate(iter('abc')). """ import unittest -from test import test_support +from test import support from itertools import repeat from collections import deque from builtins import len as _len @@ -211,7 +211,7 @@ def test_main(): TestList, TestListReversed, ] - test_support.run_unittest(*unittests) + support.run_unittest(*unittests) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py index 335e47d..3957f41 100644 --- a/Lib/test/test_itertools.py +++ b/Lib/test/test_itertools.py @@ -1,12 +1,12 @@ import unittest -from test import test_support +from test import support from itertools import * from weakref import proxy import sys import operator import random from functools import reduce -maxsize = test_support.MAX_Py_ssize_t +maxsize = support.MAX_Py_ssize_t minsize = -maxsize-1 def lzip(*args): @@ -1391,20 +1391,20 @@ def test_main(verbose=None): test_classes = (TestBasicOps, TestVariousIteratorArgs, TestGC, RegressionTests, LengthTransparency, SubclassWithKwargsTest, TestExamples) - test_support.run_unittest(*test_classes) + support.run_unittest(*test_classes) # 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) # doctest the examples in the library reference - test_support.run_doctest(sys.modules[__name__], verbose) + support.run_doctest(sys.modules[__name__], verbose) if __name__ == "__main__": test_main(verbose=True) diff --git a/Lib/test/test_json.py b/Lib/test/test_json.py index 17ccdee..17e1daf 100644 --- a/Lib/test/test_json.py +++ b/Lib/test/test_json.py @@ -6,12 +6,12 @@ be run. """ import json.tests -import test.test_support +import test.support def test_main(): - test.test_support.run_unittest(json.tests.test_suite()) - test.test_support.run_doctest(json) + test.support.run_unittest(json.tests.test_suite()) + test.support.run_doctest(json) if __name__ == "__main__": diff --git a/Lib/test/test_keywordonlyarg.py b/Lib/test/test_keywordonlyarg.py index e64a6cd..aa7d3db 100644 --- a/Lib/test/test_keywordonlyarg.py +++ b/Lib/test/test_keywordonlyarg.py @@ -6,7 +6,7 @@ __author__ = "Jiwon Seo" __email__ = "seojiwon at gmail dot com" import unittest -from test.test_support import run_unittest +from test.support import run_unittest def posonly_sum(pos_arg1, *arg, **kwarg): return pos_arg1 + sum(arg) + sum(kwarg.values()) diff --git a/Lib/test/test_kqueue.py b/Lib/test/test_kqueue.py index 310eb33..ef43633 100644 --- a/Lib/test/test_kqueue.py +++ b/Lib/test/test_kqueue.py @@ -8,9 +8,9 @@ import select import sys import unittest -from test import test_support +from test import support if not hasattr(select, "kqueue"): - raise test_support.TestSkipped("test works only on BSD") + raise support.TestSkipped("test works only on BSD") class TestKQueue(unittest.TestCase): def test_create_queue(self): @@ -160,7 +160,7 @@ class TestKQueue(unittest.TestCase): serverSocket.close() def test_main(): - test_support.run_unittest(TestKQueue) + support.run_unittest(TestKQueue) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_largefile.py b/Lib/test/test_largefile.py index 0856346..8060ea0 100644 --- a/Lib/test/test_largefile.py +++ b/Lib/test/test_largefile.py @@ -5,7 +5,7 @@ import os import stat import sys import unittest -from test.test_support import run_unittest, TESTFN, verbose, requires, \ +from test.support import run_unittest, TESTFN, verbose, requires, \ TestSkipped, unlink try: diff --git a/Lib/test/test_lib2to3.py b/Lib/test/test_lib2to3.py index 161b9dd..9bd4496 100644 --- a/Lib/test/test_lib2to3.py +++ b/Lib/test/test_lib2to3.py @@ -2,7 +2,7 @@ # because of running from lib2to3.tests import test_fixers, test_pytree, test_util import unittest -from test.test_support import run_unittest +from test.support import run_unittest def suite(): tests = unittest.TestSuite() diff --git a/Lib/test/test_list.py b/Lib/test/test_list.py index 3b85117..5184321 100644 --- a/Lib/test/test_list.py +++ b/Lib/test/test_list.py @@ -1,5 +1,5 @@ import sys -from test import test_support, list_tests +from test import support, list_tests class ListTest(list_tests.CommonTest): type2test = list @@ -43,7 +43,7 @@ class ListTest(list_tests.CommonTest): self.assertRaises((MemoryError, OverflowError), imul, lst, n) def test_main(verbose=None): - test_support.run_unittest(ListTest) + support.run_unittest(ListTest) # verify reference counting import sys @@ -51,7 +51,7 @@ def test_main(verbose=None): import gc counts = [None] * 5 for i in range(len(counts)): - test_support.run_unittest(ListTest) + support.run_unittest(ListTest) gc.collect() counts[i] = sys.gettotalrefcount() print(counts) diff --git a/Lib/test/test_listcomps.py b/Lib/test/test_listcomps.py index 684b716..663ccbb 100644 --- a/Lib/test/test_listcomps.py +++ b/Lib/test/test_listcomps.py @@ -130,16 +130,16 @@ __test__ = {'doctests' : doctests} def test_main(verbose=None): import sys - from test import test_support + from test import support from test import test_listcomps - test_support.run_doctest(test_listcomps, verbose) + support.run_doctest(test_listcomps, verbose) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in range(len(counts)): - test_support.run_doctest(test_genexps, verbose) + support.run_doctest(test_genexps, verbose) gc.collect() counts[i] = sys.gettotalrefcount() print(counts) @@ -278,16 +278,16 @@ __test__ = {'doctests' : doctests} def test_main(verbose=None): import sys - from test import test_support + from test import support from test import test_listcomps - test_support.run_doctest(test_listcomps, verbose) + support.run_doctest(test_listcomps, verbose) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in range(len(counts)): - test_support.run_doctest(test_genexps, verbose) + support.run_doctest(test_genexps, verbose) gc.collect() counts[i] = sys.gettotalrefcount() print(counts) @@ -426,16 +426,16 @@ __test__ = {'doctests' : doctests} def test_main(verbose=None): import sys - from test import test_support + from test import support from test import test_listcomps - test_support.run_doctest(test_listcomps, verbose) + support.run_doctest(test_listcomps, verbose) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in range(len(counts)): - test_support.run_doctest(test_listcomps, verbose) + support.run_doctest(test_listcomps, verbose) gc.collect() counts[i] = sys.gettotalrefcount() print(counts) diff --git a/Lib/test/test_locale.py b/Lib/test/test_locale.py index ef1f5c2..6d13058 100644 --- a/Lib/test/test_locale.py +++ b/Lib/test/test_locale.py @@ -1,4 +1,4 @@ -from test.test_support import verbose, TestSkipped +from test.support import verbose, TestSkipped import locale import sys diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index b6da0ae..888ac72 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -38,7 +38,7 @@ import string import struct import sys import tempfile -from test.test_support import captured_stdout, run_with_locale, run_unittest +from test.support import captured_stdout, run_with_locale, run_unittest import textwrap import threading import time diff --git a/Lib/test/test_long.py b/Lib/test/test_long.py index 256a1ce..21881c9 100644 --- a/Lib/test/test_long.py +++ b/Lib/test/test_long.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support import sys import random @@ -771,7 +771,7 @@ class LongTest(unittest.TestCase): self.assertRaises(OverflowError, int, float('nan')) def test_main(): - test_support.run_unittest(LongTest) + support.run_unittest(LongTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_long_future.py b/Lib/test/test_long_future.py index 36840b4..428b03a 100644 --- a/Lib/test/test_long_future.py +++ b/Lib/test/test_long_future.py @@ -4,7 +4,7 @@ from __future__ import division # trick just part of test_long into using future division. import unittest -from test.test_support import run_unittest +from test.support import run_unittest class TrueDivisionTests(unittest.TestCase): def test(self): diff --git a/Lib/test/test_longexp.py b/Lib/test/test_longexp.py index dd222a1..1b40d02 100644 --- a/Lib/test/test_longexp.py +++ b/Lib/test/test_longexp.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support class LongExpText(unittest.TestCase): def test_longexp(self): @@ -8,7 +8,7 @@ class LongExpText(unittest.TestCase): self.assertEqual(len(l), REPS) def test_main(): - test_support.run_unittest(LongExpText) + support.run_unittest(LongExpText) if __name__=="__main__": test_main() diff --git a/Lib/test/test_macpath.py b/Lib/test/test_macpath.py index 9d36375..38b85e5 100644 --- a/Lib/test/test_macpath.py +++ b/Lib/test/test_macpath.py @@ -1,5 +1,5 @@ import macpath -from test import test_support +from test import support import unittest @@ -56,7 +56,7 @@ class MacPathTestCase(unittest.TestCase): def test_main(): - test_support.run_unittest(MacPathTestCase) + support.run_unittest(MacPathTestCase) if __name__ == "__main__": diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py index 43b864c..783323f 100644 --- a/Lib/test/test_mailbox.py +++ b/Lib/test/test_mailbox.py @@ -7,7 +7,7 @@ import email import email.message import re import io -from test import test_support +from test import support import unittest import mailbox import glob @@ -52,7 +52,7 @@ class TestMailbox(TestBase): _template = 'From: foo\n\n%s' def setUp(self): - self._path = test_support.TESTFN + self._path = support.TESTFN self._delete_recursively(self._path) self._box = self._factory(self._path) @@ -715,7 +715,7 @@ class _TestMboxMMDF(TestMailbox): self._box.close() self._delete_recursively(self._path) for lock_remnant in glob.glob(self._path + '.*'): - test_support.unlink(lock_remnant) + support.unlink(lock_remnant) def test_add_from_string(self): # Add a string starting with 'From ' to the mailbox @@ -938,7 +938,7 @@ class TestBabyl(TestMailbox): self._box.close() self._delete_recursively(self._path) for lock_remnant in glob.glob(self._path + '.*'): - test_support.unlink(lock_remnant) + support.unlink(lock_remnant) def test_labels(self): # Get labels from the mailbox @@ -964,7 +964,7 @@ class TestMessage(TestBase): _factory = mailbox.Message # Overridden by subclasses to reuse tests def setUp(self): - self._path = test_support.TESTFN + self._path = support.TESTFN def tearDown(self): self._delete_recursively(self._path) @@ -1580,7 +1580,7 @@ class TestProxyFileBase(TestBase): class TestProxyFile(TestProxyFileBase): def setUp(self): - self._path = test_support.TESTFN + self._path = support.TESTFN self._file = open(self._path, 'wb+') def tearDown(self): @@ -1629,7 +1629,7 @@ class TestProxyFile(TestProxyFileBase): class TestPartialFile(TestProxyFileBase): def setUp(self): - self._path = test_support.TESTFN + self._path = support.TESTFN self._file = open(self._path, 'wb+') def tearDown(self): @@ -1692,7 +1692,7 @@ class MaildirTestCase(unittest.TestCase): def setUp(self): # create a new maildir mailbox to work with: - self._dir = test_support.TESTFN + self._dir = support.TESTFN os.mkdir(self._dir) os.mkdir(os.path.join(self._dir, "cur")) os.mkdir(os.path.join(self._dir, "tmp")) @@ -1733,7 +1733,7 @@ class MaildirTestCase(unittest.TestCase): """Test an empty maildir mailbox""" # Test for regression on bug #117490: # Make sure the boxes attribute actually gets set. - self.mbox = mailbox.Maildir(test_support.TESTFN) + self.mbox = mailbox.Maildir(support.TESTFN) #self.assert_(hasattr(self.mbox, "boxes")) #self.assertEqual(len(self.mbox.boxes), 0) self.assert_(self.mbox.next() is None) @@ -1741,7 +1741,7 @@ class MaildirTestCase(unittest.TestCase): def test_nonempty_maildir_cur(self): self.createMessage("cur") - self.mbox = mailbox.Maildir(test_support.TESTFN) + self.mbox = mailbox.Maildir(support.TESTFN) #self.assertEqual(len(self.mbox.boxes), 1) self.assert_(self.mbox.next() is not None) self.assert_(self.mbox.next() is None) @@ -1749,7 +1749,7 @@ class MaildirTestCase(unittest.TestCase): def test_nonempty_maildir_new(self): self.createMessage("new") - self.mbox = mailbox.Maildir(test_support.TESTFN) + self.mbox = mailbox.Maildir(support.TESTFN) #self.assertEqual(len(self.mbox.boxes), 1) self.assert_(self.mbox.next() is not None) self.assert_(self.mbox.next() is None) @@ -1758,7 +1758,7 @@ class MaildirTestCase(unittest.TestCase): def test_nonempty_maildir_both(self): self.createMessage("cur") self.createMessage("new") - self.mbox = mailbox.Maildir(test_support.TESTFN) + self.mbox = mailbox.Maildir(support.TESTFN) #self.assertEqual(len(self.mbox.boxes), 2) self.assert_(self.mbox.next() is not None) self.assert_(self.mbox.next() is not None) @@ -1856,8 +1856,8 @@ def test_main(): TestMHMessage, TestBabylMessage, TestMMDFMessage, TestMessageConversion, TestProxyFile, TestPartialFile, MaildirTestCase) - test_support.run_unittest(*tests) - test_support.reap_children() + support.run_unittest(*tests) + support.reap_children() if __name__ == '__main__': diff --git a/Lib/test/test_marshal.py b/Lib/test/test_marshal.py index 838207a..83ab852 100644 --- a/Lib/test/test_marshal.py +++ b/Lib/test/test_marshal.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -from test import test_support +from test import support import marshal import sys import unittest @@ -11,19 +11,19 @@ class HelperMixin: new = marshal.loads(marshal.dumps(sample, *extra)) self.assertEqual(sample, new) try: - f = open(test_support.TESTFN, "wb") + f = open(support.TESTFN, "wb") try: marshal.dump(sample, f, *extra) finally: f.close() - f = open(test_support.TESTFN, "rb") + f = open(support.TESTFN, "rb") try: new = marshal.load(f) finally: f.close() self.assertEqual(sample, new) finally: - test_support.unlink(test_support.TESTFN) + support.unlink(support.TESTFN) class IntTestCase(unittest.TestCase, HelperMixin): def test_ints(self): @@ -208,7 +208,7 @@ class BugsTestCase(unittest.TestCase): def test_main(): - test_support.run_unittest(IntTestCase, + support.run_unittest(IntTestCase, FloatTestCase, StringTestCase, CodeTestCase, diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py index ff8db7c..f24bdb3 100644 --- a/Lib/test/test_math.py +++ b/Lib/test/test_math.py @@ -1,7 +1,7 @@ # Python test set -- math module # XXXX Should not do tests around zero only -from test.test_support import run_unittest, verbose +from test.support import run_unittest, verbose import unittest import math import os diff --git a/Lib/test/test_memoryio.py b/Lib/test/test_memoryio.py index 7857587..2d91cbd 100644 --- a/Lib/test/test_memoryio.py +++ b/Lib/test/test_memoryio.py @@ -4,7 +4,7 @@ BytesIO -- for bytes """ import unittest -from test import test_support +from test import support import io import sys @@ -408,7 +408,7 @@ def test_main(): tests = [PyBytesIOTest, PyStringIOTest] if has_c_implementation: tests.extend([CBytesIOTest]) - test_support.run_unittest(*tests) + support.run_unittest(*tests) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_memoryview.py b/Lib/test/test_memoryview.py index 27adc5e..b3d478d 100644 --- a/Lib/test/test_memoryview.py +++ b/Lib/test/test_memoryview.py @@ -4,7 +4,7 @@ XXX We need more tests! Some tests are in test_bytes """ import unittest -import test.test_support +import test.support class MemoryviewTest(unittest.TestCase): @@ -18,7 +18,7 @@ class MemoryviewTest(unittest.TestCase): self.assertRaises(TypeError, memoryview, ob, argument=True) def test_main(): - test.test_support.run_unittest(MemoryviewTest) + test.support.run_unittest(MemoryviewTest) if __name__ == "__main__": diff --git a/Lib/test/test_metaclass.py b/Lib/test/test_metaclass.py index 733418e..d8195dd 100644 --- a/Lib/test/test_metaclass.py +++ b/Lib/test/test_metaclass.py @@ -235,9 +235,9 @@ Make sure it works with subclassing. __test__ = {'doctests' : doctests} def test_main(verbose=False): - from test import test_support + from test import support from test import test_metaclass - test_support.run_doctest(test_metaclass, verbose) + support.run_doctest(test_metaclass, verbose) if __name__ == "__main__": test_main(verbose=True) diff --git a/Lib/test/test_mimetools.py b/Lib/test/test_mimetools.py index ef333f5..1dc9178 100644 --- a/Lib/test/test_mimetools.py +++ b/Lib/test/test_mimetools.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support import string, mimetools import io @@ -70,7 +70,7 @@ class MimeToolsTest(unittest.TestCase): self.assertEqual(msg.getencoding(), "8bit") def test_main(): - test_support.run_unittest(MimeToolsTest) + support.run_unittest(MimeToolsTest) if __name__=="__main__": test_main() diff --git a/Lib/test/test_mimetypes.py b/Lib/test/test_mimetypes.py index 53de072..9651a60 100644 --- a/Lib/test/test_mimetypes.py +++ b/Lib/test/test_mimetypes.py @@ -2,7 +2,7 @@ import mimetypes import io import unittest -from test import test_support +from test import support # Tell it we don't know about external files: mimetypes.knownfiles = [] @@ -63,7 +63,7 @@ class MimeTypesTestCase(unittest.TestCase): def test_main(): - test_support.run_unittest(MimeTypesTestCase) + support.run_unittest(MimeTypesTestCase) if __name__ == "__main__": diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py index 9ea60a9..20130c3 100644 --- a/Lib/test/test_minidom.py +++ b/Lib/test/test_minidom.py @@ -4,7 +4,7 @@ import os import sys import pickle from io import StringIO -from test.test_support import verbose, run_unittest, TestSkipped +from test.support import verbose, run_unittest, TestSkipped import unittest import xml.dom diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py index f01b9df..0b5202a 100644 --- a/Lib/test/test_mmap.py +++ b/Lib/test/test_mmap.py @@ -1,4 +1,4 @@ -from test.test_support import TESTFN, run_unittest +from test.support import TESTFN, run_unittest import mmap import unittest import os, re diff --git a/Lib/test/test_module.py b/Lib/test/test_module.py index 35c765e..45556e8 100644 --- a/Lib/test/test_module.py +++ b/Lib/test/test_module.py @@ -1,6 +1,6 @@ # Test the module type import unittest -from test.test_support import run_unittest +from test.support import run_unittest import sys ModuleType = type(sys) diff --git a/Lib/test/test_modulefinder.py b/Lib/test/test_modulefinder.py index 80c06d7..85bc669 100644 --- a/Lib/test/test_modulefinder.py +++ b/Lib/test/test_modulefinder.py @@ -4,7 +4,7 @@ import unittest import distutils.dir_util import tempfile -from test import test_support +from test import support try: set except NameError: from sets import Set as set @@ -258,7 +258,7 @@ class ModuleFinderTest(unittest.TestCase): def test_main(): distutils.log.set_threshold(distutils.log.WARN) - test_support.run_unittest(ModuleFinderTest) + support.run_unittest(ModuleFinderTest) if __name__ == "__main__": unittest.main() diff --git a/Lib/test/test_multibytecodec.py b/Lib/test/test_multibytecodec.py index 615ad8b..0eb422e 100644 --- a/Lib/test/test_multibytecodec.py +++ b/Lib/test/test_multibytecodec.py @@ -4,9 +4,9 @@ # Unit test for multibytecodec itself # -from test import test_support +from test import support from test import test_multibytecodec_support -from test.test_support import TESTFN +from test.support import TESTFN import unittest, io, codecs, sys, os ALL_CJKENCODINGS = [ @@ -51,7 +51,7 @@ class Test_MultibyteCodec(unittest.TestCase): print('# coding:', enc, file=io.open(TESTFN, 'w')) exec(open(TESTFN).read()) finally: - test_support.unlink(TESTFN) + support.unlink(TESTFN) class Test_IncrementalEncoder(unittest.TestCase): @@ -151,7 +151,7 @@ class Test_StreamReader(unittest.TestCase): finally: f.close() finally: - test_support.unlink(TESTFN) + support.unlink(TESTFN) class Test_StreamWriter(unittest.TestCase): if len('\U00012345') == 2: # UCS2 @@ -235,7 +235,7 @@ class Test_ISO2022(unittest.TestCase): myunichr(x).encode('iso_2022_jp', 'ignore') def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_multibytecodec_support.py b/Lib/test/test_multibytecodec_support.py index 5508c9d..3e0476e 100644 --- a/Lib/test/test_multibytecodec_support.py +++ b/Lib/test/test_multibytecodec_support.py @@ -6,7 +6,7 @@ import sys, codecs import unittest, re -from test import test_support +from test import support from io import BytesIO class TestBase: @@ -279,10 +279,10 @@ class TestBase_Mapping(unittest.TestCase): try: self.open_mapping_file() # test it to report the error early except IOError: - raise test_support.TestSkipped("Could not retrieve "+self.mapfileurl) + raise support.TestSkipped("Could not retrieve "+self.mapfileurl) def open_mapping_file(self): - return test_support.open_urlresource(self.mapfileurl) + return support.open_urlresource(self.mapfileurl) def test_mapping_file(self): if self.mapfileurl.endswith('.xml'): diff --git a/Lib/test/test_mutants.py b/Lib/test/test_mutants.py index 7fff784..b43fa47 100644 --- a/Lib/test/test_mutants.py +++ b/Lib/test/test_mutants.py @@ -1,4 +1,4 @@ -from test.test_support import verbose, TESTFN +from test.support import verbose, TESTFN import random import os diff --git a/Lib/test/test_netrc.py b/Lib/test/test_netrc.py index 4a2cb0d..938e255 100644 --- a/Lib/test/test_netrc.py +++ b/Lib/test/test_netrc.py @@ -1,6 +1,6 @@ import netrc, os, unittest, sys -from test import test_support +from test import support TEST_NETRC = """ machine foo login log1 password pass1 account acct1 @@ -17,7 +17,7 @@ default login log2 password pass2 """ -temp_filename = test_support.TESTFN +temp_filename = support.TESTFN class NetrcTestCase(unittest.TestCase): @@ -41,7 +41,7 @@ class NetrcTestCase(unittest.TestCase): self.assert_(nrc.hosts['default'] == ('log2', None, 'pass2')) def test_main(): - test_support.run_unittest(NetrcTestCase) + support.run_unittest(NetrcTestCase) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_nis.py b/Lib/test/test_nis.py index 757edd6..8a7efcf 100644 --- a/Lib/test/test_nis.py +++ b/Lib/test/test_nis.py @@ -1,4 +1,4 @@ -from test import test_support +from test import support import unittest import nis @@ -8,7 +8,7 @@ class NisTests(unittest.TestCase): maps = nis.maps() except nis.error as msg: # NIS is probably not active, so this test isn't useful - if test_support.verbose: + if support.verbose: print("Test Skipped:", msg) # Can't raise TestSkipped as regrtest only recognizes the exception # import time. @@ -37,7 +37,7 @@ class NisTests(unittest.TestCase): break def test_main(): - test_support.run_unittest(NisTests) + support.run_unittest(NisTests) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_normalization.py b/Lib/test/test_normalization.py index ae49996..920ce27 100644 --- a/Lib/test/test_normalization.py +++ b/Lib/test/test_normalization.py @@ -1,4 +1,4 @@ -from test.test_support import run_unittest, open_urlresource +from test.support import run_unittest, open_urlresource import unittest import sys diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py index 627b167..fa40db8 100644 --- a/Lib/test/test_ntpath.py +++ b/Lib/test/test_ntpath.py @@ -1,7 +1,7 @@ import ntpath import os -from test.test_support import verbose, TestFailed -import test.test_support as test_support +from test.support import verbose, TestFailed +import test.support as support import unittest @@ -180,7 +180,7 @@ class TestNtpath(unittest.TestCase): def test_main(): - test_support.run_unittest(TestNtpath) + support.run_unittest(TestNtpath) if __name__ == "__main__": diff --git a/Lib/test/test_opcodes.py b/Lib/test/test_opcodes.py index d65c5cc..42ba600 100644 --- a/Lib/test/test_opcodes.py +++ b/Lib/test/test_opcodes.py @@ -1,6 +1,6 @@ # Python test set -- part 2, opcodes -from test.test_support import run_unittest +from test.support import run_unittest import unittest class OpcodeTest(unittest.TestCase): diff --git a/Lib/test/test_openpty.py b/Lib/test/test_openpty.py index f935496..9272c85 100644 --- a/Lib/test/test_openpty.py +++ b/Lib/test/test_openpty.py @@ -1,7 +1,7 @@ # Test to see if openpty works. (But don't worry if it isn't available.) import os, unittest -from test.test_support import run_unittest, TestSkipped +from test.support import run_unittest, TestSkipped if not hasattr(os, "openpty"): raise TestSkipped("No openpty() available.") diff --git a/Lib/test/test_operator.py b/Lib/test/test_operator.py index d6146ee..2a02dac 100644 --- a/Lib/test/test_operator.py +++ b/Lib/test/test_operator.py @@ -1,7 +1,7 @@ import operator import unittest -from test import test_support +from test import support class Seq1: def __init__(self, lst): @@ -465,14 +465,14 @@ def test_main(verbose=None): OperatorTestCase, ) - test_support.run_unittest(*test_classes) + support.run_unittest(*test_classes) # 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_optparse.py b/Lib/test/test_optparse.py index 71de869..be2867c 100644 --- a/Lib/test/test_optparse.py +++ b/Lib/test/test_optparse.py @@ -15,7 +15,7 @@ import copy import unittest from io import StringIO -from test import test_support +from test import support from optparse import make_option, Option, IndentedHelpFormatter, \ @@ -1004,10 +1004,10 @@ class TestExtendAddTypes(BaseTest): self.parser.add_option("-f", "--file", type="file", dest="file") def tearDown(self): - if os.path.isdir(test_support.TESTFN): - os.rmdir(test_support.TESTFN) - elif os.path.isfile(test_support.TESTFN): - os.unlink(test_support.TESTFN) + if os.path.isdir(support.TESTFN): + os.rmdir(support.TESTFN) + elif os.path.isfile(support.TESTFN): + os.unlink(support.TESTFN) class MyOption (Option): def check_file(option, opt, value): @@ -1022,21 +1022,21 @@ class TestExtendAddTypes(BaseTest): TYPE_CHECKER["file"] = check_file def test_filetype_ok(self): - open(test_support.TESTFN, "w").close() - self.assertParseOK(["--file", test_support.TESTFN, "-afoo"], - {'file': test_support.TESTFN, 'a': 'foo'}, + open(support.TESTFN, "w").close() + self.assertParseOK(["--file", support.TESTFN, "-afoo"], + {'file': support.TESTFN, 'a': 'foo'}, []) def test_filetype_noexist(self): - self.assertParseFail(["--file", test_support.TESTFN, "-afoo"], + self.assertParseFail(["--file", support.TESTFN, "-afoo"], "%s: file does not exist" % - test_support.TESTFN) + support.TESTFN) def test_filetype_notfile(self): - os.mkdir(test_support.TESTFN) - self.assertParseFail(["--file", test_support.TESTFN, "-afoo"], + os.mkdir(support.TESTFN) + self.assertParseFail(["--file", support.TESTFN, "-afoo"], "%s: not a regular file" % - test_support.TESTFN) + support.TESTFN) class TestExtendAddActions(BaseTest): @@ -1611,7 +1611,7 @@ class TestParseNumber(BaseTest): def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index 503244a..f0b734e 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -6,22 +6,22 @@ import os import unittest import warnings import sys -from test import test_support +from test import support # Tests creating TESTFN class FileTests(unittest.TestCase): def setUp(self): - if os.path.exists(test_support.TESTFN): - os.unlink(test_support.TESTFN) + if os.path.exists(support.TESTFN): + os.unlink(support.TESTFN) tearDown = setUp def test_access(self): - f = os.open(test_support.TESTFN, os.O_CREAT|os.O_RDWR) + f = os.open(support.TESTFN, os.O_CREAT|os.O_RDWR) os.close(f) - self.assert_(os.access(test_support.TESTFN, os.W_OK)) + self.assert_(os.access(support.TESTFN, os.W_OK)) def test_closerange(self): - f = os.open(test_support.TESTFN, os.O_CREAT|os.O_RDWR) + f = os.open(support.TESTFN, os.O_CREAT|os.O_RDWR) # close a fd that is open, and one that isn't os.closerange(f, f+2) self.assertRaises(OSError, os.write, f, "a") @@ -29,12 +29,12 @@ class FileTests(unittest.TestCase): class TemporaryFileTests(unittest.TestCase): def setUp(self): self.files = [] - os.mkdir(test_support.TESTFN) + os.mkdir(support.TESTFN) def tearDown(self): for name in self.files: os.unlink(name) - os.rmdir(test_support.TESTFN) + os.rmdir(support.TESTFN) def check_tempfile(self, name): # make sure it doesn't already exist: @@ -51,10 +51,10 @@ class TemporaryFileTests(unittest.TestCase): r"test_os$") self.check_tempfile(os.tempnam()) - name = os.tempnam(test_support.TESTFN) + name = os.tempnam(support.TESTFN) self.check_tempfile(name) - name = os.tempnam(test_support.TESTFN, "pfx") + name = os.tempnam(support.TESTFN, "pfx") self.assert_(os.path.basename(name)[:3] == "pfx") self.check_tempfile(name) @@ -137,15 +137,15 @@ class TemporaryFileTests(unittest.TestCase): # Test attributes on return values from os.*stat* family. class StatAttributeTests(unittest.TestCase): def setUp(self): - os.mkdir(test_support.TESTFN) - self.fname = os.path.join(test_support.TESTFN, "f1") + os.mkdir(support.TESTFN) + self.fname = os.path.join(support.TESTFN, "f1") f = open(self.fname, 'wb') f.write(b"ABC") f.close() def tearDown(self): os.unlink(self.fname) - os.rmdir(test_support.TESTFN) + os.rmdir(support.TESTFN) def test_stat_attributes(self): if not hasattr(os, "stat"): @@ -261,11 +261,11 @@ class StatAttributeTests(unittest.TestCase): def test_utime_dir(self): delta = 1000000 - st = os.stat(test_support.TESTFN) + st = os.stat(support.TESTFN) # round to int, because some systems may support sub-second # time stamps in stat, but not in utime. - os.utime(test_support.TESTFN, (st.st_atime, int(st.st_mtime-delta))) - st2 = os.stat(test_support.TESTFN) + os.utime(support.TESTFN, (st.st_atime, int(st.st_mtime-delta))) + st2 = os.stat(support.TESTFN) self.assertEquals(st2.st_mtime, int(st.st_mtime-delta)) # Restrict test to Win32, since there is no guarantee other @@ -280,7 +280,7 @@ class StatAttributeTests(unittest.TestCase): if kernel32.GetVolumeInformationA(root, None, 0, None, None, None, buf, len(buf)): return buf.value - if get_file_system(test_support.TESTFN) == "NTFS": + if get_file_system(support.TESTFN) == "NTFS": def test_1565150(self): t1 = 1159195039.25 os.utime(self.fname, (t1, t1)) @@ -364,7 +364,7 @@ class WalkTests(unittest.TestCase): # link/ a symlink to TESTFN.2 # TEST2/ # tmp4 a lone file - walk_path = join(test_support.TESTFN, "TEST1") + walk_path = join(support.TESTFN, "TEST1") sub1_path = join(walk_path, "SUB1") sub11_path = join(sub1_path, "SUB11") sub2_path = join(walk_path, "SUB2") @@ -372,8 +372,8 @@ class WalkTests(unittest.TestCase): tmp2_path = join(sub1_path, "tmp2") tmp3_path = join(sub2_path, "tmp3") link_path = join(sub2_path, "link") - t2_path = join(test_support.TESTFN, "TEST2") - tmp4_path = join(test_support.TESTFN, "TEST2", "tmp4") + t2_path = join(support.TESTFN, "TEST2") + tmp4_path = join(support.TESTFN, "TEST2", "tmp4") # Create stuff. os.makedirs(sub11_path) @@ -442,7 +442,7 @@ class WalkTests(unittest.TestCase): # Windows, which doesn't have a recursive delete command. The # (not so) subtlety is that rmdir will fail unless the dir's # kids are removed first, so bottom up is essential. - for root, dirs, files in os.walk(test_support.TESTFN, topdown=False): + for root, dirs, files in os.walk(support.TESTFN, topdown=False): for name in files: os.remove(os.path.join(root, name)) for name in dirs: @@ -451,14 +451,14 @@ class WalkTests(unittest.TestCase): os.rmdir(dirname) else: os.remove(dirname) - os.rmdir(test_support.TESTFN) + os.rmdir(support.TESTFN) class MakedirTests(unittest.TestCase): def setUp(self): - os.mkdir(test_support.TESTFN) + os.mkdir(support.TESTFN) def test_makedir(self): - base = test_support.TESTFN + base = support.TESTFN path = os.path.join(base, 'dir1', 'dir2', 'dir3') os.makedirs(path) # Should work path = os.path.join(base, 'dir1', 'dir2', 'dir3', 'dir4') @@ -473,12 +473,12 @@ class MakedirTests(unittest.TestCase): os.makedirs(path) def tearDown(self): - path = os.path.join(test_support.TESTFN, 'dir1', 'dir2', 'dir3', + path = os.path.join(support.TESTFN, 'dir1', 'dir2', 'dir3', 'dir4', 'dir5', 'dir6') # If the tests failed, the bottom-most directory ('../dir6') # may not have been created, so we look for the outermost directory # that exists. - while not os.path.exists(path) and path != test_support.TESTFN: + while not os.path.exists(path) and path != support.TESTFN: path = os.path.dirname(path) os.removedirs(path) @@ -511,32 +511,32 @@ class ExecTests(unittest.TestCase): class Win32ErrorTests(unittest.TestCase): def test_rename(self): - self.assertRaises(WindowsError, os.rename, test_support.TESTFN, test_support.TESTFN+".bak") + self.assertRaises(WindowsError, os.rename, support.TESTFN, support.TESTFN+".bak") def test_remove(self): - self.assertRaises(WindowsError, os.remove, test_support.TESTFN) + self.assertRaises(WindowsError, os.remove, support.TESTFN) def test_chdir(self): - self.assertRaises(WindowsError, os.chdir, test_support.TESTFN) + self.assertRaises(WindowsError, os.chdir, support.TESTFN) def test_mkdir(self): - self.assertRaises(WindowsError, os.chdir, test_support.TESTFN) + self.assertRaises(WindowsError, os.chdir, support.TESTFN) def test_utime(self): - self.assertRaises(WindowsError, os.utime, test_support.TESTFN, None) + self.assertRaises(WindowsError, os.utime, support.TESTFN, None) def test_access(self): - self.assertRaises(WindowsError, os.utime, test_support.TESTFN, 0) + self.assertRaises(WindowsError, os.utime, support.TESTFN, 0) def test_chmod(self): - self.assertRaises(WindowsError, os.utime, test_support.TESTFN, 0) + self.assertRaises(WindowsError, os.utime, support.TESTFN, 0) if sys.platform != 'win32': class Win32ErrorTests(unittest.TestCase): pass def test_main(): - test_support.run_unittest( + support.run_unittest( FileTests, StatAttributeTests, EnvironTests, diff --git a/Lib/test/test_ossaudiodev.py b/Lib/test/test_ossaudiodev.py index 8f9bf6f..6f8de97 100644 --- a/Lib/test/test_ossaudiodev.py +++ b/Lib/test/test_ossaudiodev.py @@ -1,7 +1,7 @@ -from test import test_support -test_support.requires('audio') +from test import support +support.requires('audio') -from test.test_support import findfile, TestSkipped +from test.support import findfile, TestSkipped import errno import ossaudiodev @@ -167,7 +167,7 @@ def test_main(): raise TestSkipped(msg) raise dsp.close() - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py index 7269ccb..e417962 100644 --- a/Lib/test/test_parser.py +++ b/Lib/test/test_parser.py @@ -1,7 +1,7 @@ import parser import unittest import sys -from test import test_support +from test import support # # First, we test that we can generate trees from valid source fragments, @@ -471,7 +471,7 @@ class ParserStackLimitTestCase(unittest.TestCase): self.assertRaises(MemoryError, parser.expr, e) def test_main(): - test_support.run_unittest( + support.run_unittest( RoundtripLegalSyntaxTestCase, IllegalSyntaxTestCase, CompileTestCase, diff --git a/Lib/test/test_peepholer.py b/Lib/test/test_peepholer.py index faa5523..f3e240e 100644 --- a/Lib/test/test_peepholer.py +++ b/Lib/test/test_peepholer.py @@ -220,16 +220,16 @@ class TestTranforms(unittest.TestCase): def test_main(verbose=None): import sys - from test import test_support + from test import support test_classes = (TestTranforms,) - test_support.run_unittest(*test_classes) + support.run_unittest(*test_classes) # 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_pep247.py b/Lib/test/test_pep247.py index 9478969..733109a 100644 --- a/Lib/test/test_pep247.py +++ b/Lib/test/test_pep247.py @@ -6,7 +6,7 @@ for hashing algorithms import hmac import unittest from hashlib import md5, sha1, sha224, sha256, sha384, sha512 -from test import test_support +from test import support class Pep247Test(unittest.TestCase): @@ -62,7 +62,7 @@ class Pep247Test(unittest.TestCase): self.check_module(hmac, key=b'abc') def test_main(): - test_support.run_unittest(Pep247Test) + support.run_unittest(Pep247Test) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_pep263.py b/Lib/test/test_pep263.py index 92065c9..17abbd8 100644 --- a/Lib/test/test_pep263.py +++ b/Lib/test/test_pep263.py @@ -2,7 +2,7 @@ # This file is marked as binary in the CVS, to prevent MacCVS from recoding it. import unittest -from test import test_support +from test import support class PEP263Test(unittest.TestCase): @@ -32,7 +32,7 @@ class PEP263Test(unittest.TestCase): self.fail() def test_main(): - test_support.run_unittest(PEP263Test) + support.run_unittest(PEP263Test) if __name__=="__main__": test_main() diff --git a/Lib/test/test_pep277.py b/Lib/test/test_pep277.py index 770b526..eac5138 100644 --- a/Lib/test/test_pep277.py +++ b/Lib/test/test_pep277.py @@ -1,9 +1,9 @@ # Test the Unicode versions of normal file functions # open, os.open, os.stat. os.listdir, os.rename, os.remove, os.mkdir, os.chdir, os.rmdir import sys, os, unittest -from test import test_support +from test import support if not os.path.supports_unicode_filenames: - raise test_support.TestSkipped("test works only on NT+") + raise support.TestSkipped("test works only on NT+") filenames = [ 'abc', @@ -28,11 +28,11 @@ def deltree(dirname): os.rmdir(dirname) class UnicodeFileTests(unittest.TestCase): - files = [os.path.join(test_support.TESTFN, f) for f in filenames] + files = [os.path.join(support.TESTFN, f) for f in filenames] def setUp(self): try: - os.mkdir(test_support.TESTFN) + os.mkdir(support.TESTFN) except OSError: pass for name in self.files: @@ -42,17 +42,17 @@ class UnicodeFileTests(unittest.TestCase): os.stat(name) def tearDown(self): - deltree(test_support.TESTFN) + deltree(support.TESTFN) def _apply_failure(self, fn, filename, expected_exception, check_fn_in_exception = True): try: fn(filename) - raise test_support.TestFailed("Expected to fail calling '%s(%r)'" + raise support.TestFailed("Expected to fail calling '%s(%r)'" % (fn.__name__, filename)) except expected_exception as details: if check_fn_in_exception and details.filename != filename: - raise test_support.TestFailed("Function '%s(%r) failed with " + raise support.TestFailed("Function '%s(%r) failed with " "bad filename in the exception: %r" % (fn.__name__, filename, details.filename)) @@ -77,10 +77,10 @@ class UnicodeFileTests(unittest.TestCase): os.stat(name) def test_listdir(self): - f1 = os.listdir(test_support.TESTFN) - f2 = os.listdir(str(test_support.TESTFN.encode("utf-8"), + f1 = os.listdir(support.TESTFN) + f2 = os.listdir(str(support.TESTFN.encode("utf-8"), sys.getfilesystemencoding())) - sf2 = set("\\".join((str(test_support.TESTFN), f)) + sf2 = set("\\".join((str(support.TESTFN), f)) for f in f2) self.failUnlessEqual(len(f1), len(self.files)) self.failUnlessEqual(sf2, set(self.files)) @@ -91,7 +91,7 @@ class UnicodeFileTests(unittest.TestCase): os.rename("tmp",name) def test_directory(self): - dirname = os.path.join(test_support.TESTFN,'Gr\xfc\xdf-\u66e8\u66e9\u66eb') + dirname = os.path.join(support.TESTFN,'Gr\xfc\xdf-\u66e8\u66e9\u66eb') filename = '\xdf-\u66e8\u66e9\u66eb' oldwd = os.getcwd() os.mkdir(dirname) @@ -106,9 +106,9 @@ class UnicodeFileTests(unittest.TestCase): def test_main(): try: - test_support.run_unittest(UnicodeFileTests) + support.run_unittest(UnicodeFileTests) finally: - deltree(test_support.TESTFN) + deltree(support.TESTFN) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_pep292.py b/Lib/test/test_pep292.py index 9820490..ce9b663 100644 --- a/Lib/test/test_pep292.py +++ b/Lib/test/test_pep292.py @@ -185,9 +185,9 @@ class TestTemplate(unittest.TestCase): def test_main(): - from test import test_support + from test import support test_classes = [TestTemplate,] - test_support.run_unittest(*test_classes) + support.run_unittest(*test_classes) if __name__ == '__main__': diff --git a/Lib/test/test_pep3120.py b/Lib/test/test_pep3120.py index 3f567bf..3bb30ca 100644 --- a/Lib/test/test_pep3120.py +++ b/Lib/test/test_pep3120.py @@ -1,7 +1,7 @@ # This file is marked as binary in the CVS, to prevent MacCVS from recoding it. import unittest -from test import test_support +from test import support class PEP3120Test(unittest.TestCase): @@ -24,7 +24,7 @@ class PEP3120Test(unittest.TestCase): self.fail("expected exception didn't occur") def test_main(): - test_support.run_unittest(PEP3120Test) + support.run_unittest(PEP3120Test) if __name__=="__main__": test_main() diff --git a/Lib/test/test_pep3131.py b/Lib/test/test_pep3131.py index 94801c9..e4c2d03 100644 --- a/Lib/test/test_pep3131.py +++ b/Lib/test/test_pep3131.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- import unittest -from test import test_support +from test import support class PEP3131Test(unittest.TestCase): @@ -23,7 +23,7 @@ class PEP3131Test(unittest.TestCase): self.fail("expected exception didn't occur") def test_main(): - test_support.run_unittest(PEP3131Test) + support.run_unittest(PEP3131Test) if __name__=="__main__": test_main() diff --git a/Lib/test/test_pep352.py b/Lib/test/test_pep352.py index db117ef..5d75667 100644 --- a/Lib/test/test_pep352.py +++ b/Lib/test/test_pep352.py @@ -1,7 +1,7 @@ import unittest import builtins import warnings -from test.test_support import run_unittest +from test.support import run_unittest import os from platform import system as platform_system diff --git a/Lib/test/test_pickle.py b/Lib/test/test_pickle.py index 67d83c7c..42fb33e 100644 --- a/Lib/test/test_pickle.py +++ b/Lib/test/test_pickle.py @@ -1,7 +1,7 @@ import pickle import io -from test import test_support +from test import support from test.pickletester import AbstractPickleTests from test.pickletester import AbstractPickleModuleTests @@ -55,12 +55,12 @@ class PersPicklerTests(AbstractPersistentPicklerTests): return u.load() def test_main(): - test_support.run_unittest( + support.run_unittest( PickleTests, PicklerTests, PersPicklerTests ) - test_support.run_doctest(pickle) + support.run_doctest(pickle) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_pickletools.py b/Lib/test/test_pickletools.py index 932dcd1..ccb6c9c 100644 --- a/Lib/test/test_pickletools.py +++ b/Lib/test/test_pickletools.py @@ -1,6 +1,6 @@ import pickle import pickletools -from test import test_support +from test import support from test.pickletester import AbstractPickleTests from test.pickletester import AbstractPickleModuleTests @@ -16,8 +16,8 @@ class OptimizedPickleTests(AbstractPickleTests, AbstractPickleModuleTests): error = KeyError def test_main(): - test_support.run_unittest(OptimizedPickleTests) - test_support.run_doctest(pickletools) + support.run_unittest(OptimizedPickleTests) + support.run_doctest(pickletools) if __name__ == "__main__": diff --git a/Lib/test/test_pipes.py b/Lib/test/test_pipes.py index 63eaa4d..d55f352 100644 --- a/Lib/test/test_pipes.py +++ b/Lib/test/test_pipes.py @@ -2,7 +2,7 @@ import pipes import os import string import unittest -from test.test_support import TESTFN, run_unittest, unlink, TestSkipped +from test.support import TESTFN, run_unittest, unlink, TestSkipped if os.name != 'posix': raise TestSkipped('pipes module only works on posix') diff --git a/Lib/test/test_pkg.py b/Lib/test/test_pkg.py index db8e844..1064617 100644 --- a/Lib/test/test_pkg.py +++ b/Lib/test/test_pkg.py @@ -5,7 +5,7 @@ import os import tempfile import textwrap import unittest -from test import test_support +from test import support # Helpers to create and destroy hierarchies. @@ -280,7 +280,7 @@ class TestPkg(unittest.TestCase): def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": diff --git a/Lib/test/test_pkgimport.py b/Lib/test/test_pkgimport.py index 316ea83..eff7b5a 100644 --- a/Lib/test/test_pkgimport.py +++ b/Lib/test/test_pkgimport.py @@ -1,6 +1,6 @@ import os, sys, string, random, tempfile, unittest -from test.test_support import run_unittest +from test.support import run_unittest class TestImport(unittest.TestCase): diff --git a/Lib/test/test_pkgutil.py b/Lib/test/test_pkgutil.py index dfd2430..169ef66 100644 --- a/Lib/test/test_pkgutil.py +++ b/Lib/test/test_pkgutil.py @@ -1,4 +1,4 @@ -from test.test_support import run_unittest +from test.support import run_unittest import unittest import sys import imp diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py index fced4d0..3758060 100644 --- a/Lib/test/test_platform.py +++ b/Lib/test/test_platform.py @@ -2,7 +2,7 @@ import sys import unittest import platform -from test import test_support +from test import support class PlatformTest(unittest.TestCase): def test_architecture(self): @@ -82,7 +82,7 @@ class PlatformTest(unittest.TestCase): res = platform.libc_ver(sys.executable) def test_main(): - test_support.run_unittest( + support.run_unittest( PlatformTest ) diff --git a/Lib/test/test_plistlib.py b/Lib/test/test_plistlib.py index 883b01f..b9a46b7 100644 --- a/Lib/test/test_plistlib.py +++ b/Lib/test/test_plistlib.py @@ -4,7 +4,7 @@ import unittest import plistlib import os import datetime -from test import test_support +from test import support # This test data was generated through Cocoa's NSDictionary class @@ -91,7 +91,7 @@ class TestPlistlib(unittest.TestCase): def tearDown(self): try: - os.unlink(test_support.TESTFN) + os.unlink(support.TESTFN) except: pass @@ -123,8 +123,8 @@ class TestPlistlib(unittest.TestCase): def test_io(self): pl = self._create() - plistlib.writePlist(pl, test_support.TESTFN) - pl2 = plistlib.readPlist(test_support.TESTFN) + plistlib.writePlist(pl, support.TESTFN) + pl2 = plistlib.readPlist(support.TESTFN) self.assertEqual(dict(pl), dict(pl2)) def test_bytes(self): @@ -177,7 +177,7 @@ class TestPlistlib(unittest.TestCase): def test_main(): - test_support.run_unittest(TestPlistlib) + support.run_unittest(TestPlistlib) if __name__ == '__main__': diff --git a/Lib/test/test_poll.py b/Lib/test/test_poll.py index d546c78..c346ba0 100644 --- a/Lib/test/test_poll.py +++ b/Lib/test/test_poll.py @@ -1,7 +1,7 @@ # Test case for the os.poll() function import os, select, random, unittest -from test.test_support import TestSkipped, TESTFN, run_unittest +from test.support import TestSkipped, TESTFN, run_unittest try: select.poll diff --git a/Lib/test/test_popen.py b/Lib/test/test_popen.py index 209bb13..d728792 100644 --- a/Lib/test/test_popen.py +++ b/Lib/test/test_popen.py @@ -5,7 +5,7 @@ """ import unittest -from test import test_support +from test import support import os, sys # Test that command-lines get down as we expect. @@ -40,10 +40,10 @@ class PopenTest(unittest.TestCase): 'foo "a \\"quoted\\" arg" bar', ["foo", 'a "quoted" arg', "bar"] ) - test_support.reap_children() + support.reap_children() def test_main(): - test_support.run_unittest(PopenTest) + support.run_unittest(PopenTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_poplib.py b/Lib/test/test_poplib.py index cd550df..14b46e3 100644 --- a/Lib/test/test_poplib.py +++ b/Lib/test/test_poplib.py @@ -4,9 +4,9 @@ import poplib import time from unittest import TestCase -from test import test_support +from test import support -HOST = test_support.HOST +HOST = support.HOST def server(evt, serv): serv.listen(5) @@ -27,7 +27,7 @@ class GeneralTests(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) threading.Thread(target=server, args=(self.evt,self.sock)).start() time.sleep(.1) @@ -65,7 +65,7 @@ class GeneralTests(TestCase): def test_main(verbose=None): - test_support.run_unittest(GeneralTests) + support.run_unittest(GeneralTests) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py index 57e9d15..f16abb2 100644 --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -1,11 +1,11 @@ "Test posix functions" -from test import test_support +from test import support try: import posix except ImportError: - raise test_support.TestSkipped("posix is not available") + raise support.TestSkipped("posix is not available") import time import os @@ -19,11 +19,11 @@ class PosixTester(unittest.TestCase): def setUp(self): # create empty file - fp = open(test_support.TESTFN, 'w+') + fp = open(support.TESTFN, 'w+') fp.close() def tearDown(self): - os.unlink(test_support.TESTFN) + os.unlink(support.TESTFN) def testNoArgFunctions(self): # test posix functions which take no arguments and have @@ -46,7 +46,7 @@ class PosixTester(unittest.TestCase): def test_fstatvfs(self): if hasattr(posix, 'fstatvfs'): - fp = open(test_support.TESTFN) + fp = open(support.TESTFN) try: self.assert_(posix.fstatvfs(fp.fileno())) finally: @@ -54,7 +54,7 @@ class PosixTester(unittest.TestCase): def test_ftruncate(self): if hasattr(posix, 'ftruncate'): - fp = open(test_support.TESTFN, 'w+') + fp = open(support.TESTFN, 'w+') try: # we need to have some data to truncate fp.write('test') @@ -65,7 +65,7 @@ class PosixTester(unittest.TestCase): def test_dup(self): if hasattr(posix, 'dup'): - fp = open(test_support.TESTFN) + fp = open(support.TESTFN) try: fd = posix.dup(fp.fileno()) self.assert_(isinstance(fd, int)) @@ -80,8 +80,8 @@ class PosixTester(unittest.TestCase): def test_dup2(self): if hasattr(posix, 'dup2'): - fp1 = open(test_support.TESTFN) - fp2 = open(test_support.TESTFN) + fp1 = open(support.TESTFN) + fp2 = open(support.TESTFN) try: posix.dup2(fp1.fileno(), fp2.fileno()) finally: @@ -89,7 +89,7 @@ class PosixTester(unittest.TestCase): fp2.close() def fdopen_helper(self, *args): - fd = os.open(test_support.TESTFN, os.O_RDONLY) + fd = os.open(support.TESTFN, os.O_RDONLY) fp2 = posix.fdopen(fd, *args) fp2.close() @@ -101,38 +101,38 @@ class PosixTester(unittest.TestCase): def test_osexlock(self): if hasattr(posix, "O_EXLOCK"): - fd = os.open(test_support.TESTFN, + fd = os.open(support.TESTFN, os.O_WRONLY|os.O_EXLOCK|os.O_CREAT) - self.assertRaises(OSError, os.open, test_support.TESTFN, + self.assertRaises(OSError, os.open, support.TESTFN, os.O_WRONLY|os.O_EXLOCK|os.O_NONBLOCK) os.close(fd) if hasattr(posix, "O_SHLOCK"): - fd = os.open(test_support.TESTFN, + fd = os.open(support.TESTFN, os.O_WRONLY|os.O_SHLOCK|os.O_CREAT) - self.assertRaises(OSError, os.open, test_support.TESTFN, + self.assertRaises(OSError, os.open, support.TESTFN, os.O_WRONLY|os.O_EXLOCK|os.O_NONBLOCK) os.close(fd) def test_osshlock(self): if hasattr(posix, "O_SHLOCK"): - fd1 = os.open(test_support.TESTFN, + fd1 = os.open(support.TESTFN, os.O_WRONLY|os.O_SHLOCK|os.O_CREAT) - fd2 = os.open(test_support.TESTFN, + fd2 = os.open(support.TESTFN, os.O_WRONLY|os.O_SHLOCK|os.O_CREAT) os.close(fd2) os.close(fd1) if hasattr(posix, "O_EXLOCK"): - fd = os.open(test_support.TESTFN, + fd = os.open(support.TESTFN, os.O_WRONLY|os.O_SHLOCK|os.O_CREAT) - self.assertRaises(OSError, os.open, test_support.TESTFN, + self.assertRaises(OSError, os.open, support.TESTFN, os.O_RDONLY|os.O_EXLOCK|os.O_NONBLOCK) os.close(fd) def test_fstat(self): if hasattr(posix, 'fstat'): - fp = open(test_support.TESTFN) + fp = open(support.TESTFN) try: self.assert_(posix.fstat(fp.fileno())) finally: @@ -140,16 +140,16 @@ class PosixTester(unittest.TestCase): def test_stat(self): if hasattr(posix, 'stat'): - self.assert_(posix.stat(test_support.TESTFN)) + self.assert_(posix.stat(support.TESTFN)) if hasattr(posix, 'chown'): def test_chown(self): # raise an OSError if the file does not exist - os.unlink(test_support.TESTFN) - self.assertRaises(OSError, posix.chown, test_support.TESTFN, -1, -1) + os.unlink(support.TESTFN) + self.assertRaises(OSError, posix.chown, support.TESTFN, -1, -1) # re-create the file - open(test_support.TESTFN, 'w').close() + open(support.TESTFN, 'w').close() if os.getuid() == 0: try: # Many linux distros have a nfsnobody user as MAX_UID-2 @@ -158,29 +158,29 @@ class PosixTester(unittest.TestCase): # This part of the test only runs when run as root. # Only scary people run their tests as root. ent = pwd.getpwnam('nfsnobody') - posix.chown(test_support.TESTFN, ent.pw_uid, ent.pw_gid) + posix.chown(support.TESTFN, ent.pw_uid, ent.pw_gid) except KeyError: pass else: # non-root cannot chown to root, raises OSError self.assertRaises(OSError, posix.chown, - test_support.TESTFN, 0, 0) + support.TESTFN, 0, 0) # test a successful chown call - posix.chown(test_support.TESTFN, os.getuid(), os.getgid()) + posix.chown(support.TESTFN, os.getuid(), os.getgid()) def test_chdir(self): if hasattr(posix, 'chdir'): posix.chdir(os.curdir) - self.assertRaises(OSError, posix.chdir, test_support.TESTFN) + self.assertRaises(OSError, posix.chdir, support.TESTFN) def test_lsdir(self): if hasattr(posix, 'lsdir'): - self.assert_(test_support.TESTFN in posix.lsdir(os.curdir)) + self.assert_(support.TESTFN in posix.lsdir(os.curdir)) def test_access(self): if hasattr(posix, 'access'): - self.assert_(posix.access(test_support.TESTFN, os.R_OK)) + self.assert_(posix.access(support.TESTFN, os.R_OK)) def test_umask(self): if hasattr(posix, 'umask'): @@ -201,24 +201,24 @@ class PosixTester(unittest.TestCase): def test_utime(self): if hasattr(posix, 'utime'): now = time.time() - posix.utime(test_support.TESTFN, None) - self.assertRaises(TypeError, posix.utime, test_support.TESTFN, (None, None)) - self.assertRaises(TypeError, posix.utime, test_support.TESTFN, (now, None)) - self.assertRaises(TypeError, posix.utime, test_support.TESTFN, (None, now)) - posix.utime(test_support.TESTFN, (int(now), int(now))) - posix.utime(test_support.TESTFN, (now, now)) + posix.utime(support.TESTFN, None) + self.assertRaises(TypeError, posix.utime, support.TESTFN, (None, None)) + self.assertRaises(TypeError, posix.utime, support.TESTFN, (now, None)) + self.assertRaises(TypeError, posix.utime, support.TESTFN, (None, now)) + posix.utime(support.TESTFN, (int(now), int(now))) + posix.utime(support.TESTFN, (now, now)) def test_chflags(self): if hasattr(posix, 'chflags'): - st = os.stat(test_support.TESTFN) + st = os.stat(support.TESTFN) if hasattr(st, 'st_flags'): - posix.chflags(test_support.TESTFN, st.st_flags) + posix.chflags(support.TESTFN, st.st_flags) def test_lchflags(self): if hasattr(posix, 'lchflags'): - st = os.stat(test_support.TESTFN) + st = os.stat(support.TESTFN) if hasattr(st, 'st_flags'): - posix.lchflags(test_support.TESTFN, st.st_flags) + posix.lchflags(support.TESTFN, st.st_flags) def test_environ(self): for k, v in posix.environ.items(): @@ -226,7 +226,7 @@ class PosixTester(unittest.TestCase): self.assertEqual(type(v), str) def test_main(): - test_support.run_unittest(PosixTester) + support.run_unittest(PosixTester) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py index a25e2b2..8a7dd72 100644 --- a/Lib/test/test_posixpath.py +++ b/Lib/test/test_posixpath.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support import posixpath, os from posixpath import realpath, abspath, join, dirname, basename, relpath @@ -7,7 +7,7 @@ from posixpath import realpath, abspath, join, dirname, basename, relpath # An absolute path to a temporary filename for testing. We can't rely on TESTFN # being an absolute path, so we need this. -ABSTFN = abspath(test_support.TESTFN) +ABSTFN = abspath(support.TESTFN) def safe_rmdir(dirname): try: @@ -22,8 +22,8 @@ class PosixPathTest(unittest.TestCase): def tearDown(self): for suffix in ["", "1", "2"]: - test_support.unlink(test_support.TESTFN + suffix) - safe_rmdir(test_support.TESTFN + suffix) + support.unlink(support.TESTFN + suffix) + safe_rmdir(support.TESTFN + suffix) def assertIs(self, a, b): self.assert_(a is b) @@ -141,50 +141,50 @@ class PosixPathTest(unittest.TestCase): self.assertNotEqual(s1[n:n+1], s2[n:n+1]) def test_getsize(self): - f = open(test_support.TESTFN, "wb") + f = open(support.TESTFN, "wb") try: f.write(b"foo") f.close() - self.assertEqual(posixpath.getsize(test_support.TESTFN), 3) + self.assertEqual(posixpath.getsize(support.TESTFN), 3) finally: if not f.closed: f.close() def test_time(self): - f = open(test_support.TESTFN, "wb") + f = open(support.TESTFN, "wb") try: f.write(b"foo") f.close() - f = open(test_support.TESTFN, "ab") + f = open(support.TESTFN, "ab") f.write(b"bar") f.close() - f = open(test_support.TESTFN, "rb") + f = open(support.TESTFN, "rb") d = f.read() f.close() self.assertEqual(d, b"foobar") self.assert_( - posixpath.getctime(test_support.TESTFN) <= - posixpath.getmtime(test_support.TESTFN) + posixpath.getctime(support.TESTFN) <= + posixpath.getmtime(support.TESTFN) ) finally: if not f.closed: f.close() def test_islink(self): - self.assertIs(posixpath.islink(test_support.TESTFN + "1"), False) - f = open(test_support.TESTFN + "1", "wb") + self.assertIs(posixpath.islink(support.TESTFN + "1"), False) + f = open(support.TESTFN + "1", "wb") try: f.write(b"foo") f.close() - self.assertIs(posixpath.islink(test_support.TESTFN + "1"), False) + self.assertIs(posixpath.islink(support.TESTFN + "1"), False) if hasattr(os, "symlink"): - os.symlink(test_support.TESTFN + "1", test_support.TESTFN + "2") - self.assertIs(posixpath.islink(test_support.TESTFN + "2"), True) - os.remove(test_support.TESTFN + "1") - self.assertIs(posixpath.islink(test_support.TESTFN + "2"), True) - self.assertIs(posixpath.exists(test_support.TESTFN + "2"), False) - self.assertIs(posixpath.lexists(test_support.TESTFN + "2"), True) + os.symlink(support.TESTFN + "1", support.TESTFN + "2") + self.assertIs(posixpath.islink(support.TESTFN + "2"), True) + os.remove(support.TESTFN + "1") + self.assertIs(posixpath.islink(support.TESTFN + "2"), True) + self.assertIs(posixpath.exists(support.TESTFN + "2"), False) + self.assertIs(posixpath.lexists(support.TESTFN + "2"), True) finally: if not f.close(): f.close() @@ -192,13 +192,13 @@ class PosixPathTest(unittest.TestCase): self.assertRaises(TypeError, posixpath.islink) def test_exists(self): - self.assertIs(posixpath.exists(test_support.TESTFN), False) - f = open(test_support.TESTFN, "wb") + self.assertIs(posixpath.exists(support.TESTFN), False) + f = open(support.TESTFN, "wb") try: f.write(b"foo") f.close() - self.assertIs(posixpath.exists(test_support.TESTFN), True) - self.assertIs(posixpath.lexists(test_support.TESTFN), True) + self.assertIs(posixpath.exists(support.TESTFN), True) + self.assertIs(posixpath.lexists(support.TESTFN), True) finally: if not f.close(): f.close() @@ -206,16 +206,16 @@ class PosixPathTest(unittest.TestCase): self.assertRaises(TypeError, posixpath.exists) def test_isdir(self): - self.assertIs(posixpath.isdir(test_support.TESTFN), False) - f = open(test_support.TESTFN, "wb") + self.assertIs(posixpath.isdir(support.TESTFN), False) + f = open(support.TESTFN, "wb") try: f.write(b"foo") f.close() - self.assertIs(posixpath.isdir(test_support.TESTFN), False) - os.remove(test_support.TESTFN) - os.mkdir(test_support.TESTFN) - self.assertIs(posixpath.isdir(test_support.TESTFN), True) - os.rmdir(test_support.TESTFN) + self.assertIs(posixpath.isdir(support.TESTFN), False) + os.remove(support.TESTFN) + os.mkdir(support.TESTFN) + self.assertIs(posixpath.isdir(support.TESTFN), True) + os.rmdir(support.TESTFN) finally: if not f.close(): f.close() @@ -223,16 +223,16 @@ class PosixPathTest(unittest.TestCase): self.assertRaises(TypeError, posixpath.isdir) def test_isfile(self): - self.assertIs(posixpath.isfile(test_support.TESTFN), False) - f = open(test_support.TESTFN, "wb") + self.assertIs(posixpath.isfile(support.TESTFN), False) + f = open(support.TESTFN, "wb") try: f.write(b"foo") f.close() - self.assertIs(posixpath.isfile(test_support.TESTFN), True) - os.remove(test_support.TESTFN) - os.mkdir(test_support.TESTFN) - self.assertIs(posixpath.isfile(test_support.TESTFN), False) - os.rmdir(test_support.TESTFN) + self.assertIs(posixpath.isfile(support.TESTFN), True) + os.remove(support.TESTFN) + os.mkdir(support.TESTFN) + self.assertIs(posixpath.isfile(support.TESTFN), False) + os.rmdir(support.TESTFN) finally: if not f.close(): f.close() @@ -240,14 +240,14 @@ class PosixPathTest(unittest.TestCase): self.assertRaises(TypeError, posixpath.isdir) def test_samefile(self): - f = open(test_support.TESTFN + "1", "wb") + f = open(support.TESTFN + "1", "wb") try: f.write(b"foo") f.close() self.assertIs( posixpath.samefile( - test_support.TESTFN + "1", - test_support.TESTFN + "1" + support.TESTFN + "1", + support.TESTFN + "1" ), True ) @@ -255,24 +255,24 @@ class PosixPathTest(unittest.TestCase): # inode information and thus, that samefile() doesn't work if hasattr(os, "symlink"): os.symlink( - test_support.TESTFN + "1", - test_support.TESTFN + "2" + support.TESTFN + "1", + support.TESTFN + "2" ) self.assertIs( posixpath.samefile( - test_support.TESTFN + "1", - test_support.TESTFN + "2" + support.TESTFN + "1", + support.TESTFN + "2" ), True ) - os.remove(test_support.TESTFN + "2") - f = open(test_support.TESTFN + "2", "wb") + os.remove(support.TESTFN + "2") + f = open(support.TESTFN + "2", "wb") f.write(b"bar") f.close() self.assertIs( posixpath.samefile( - test_support.TESTFN + "1", - test_support.TESTFN + "2" + support.TESTFN + "1", + support.TESTFN + "2" ), False ) @@ -283,14 +283,14 @@ class PosixPathTest(unittest.TestCase): self.assertRaises(TypeError, posixpath.samefile) def test_samestat(self): - f = open(test_support.TESTFN + "1", "wb") + f = open(support.TESTFN + "1", "wb") try: f.write(b"foo") f.close() self.assertIs( posixpath.samestat( - os.stat(test_support.TESTFN + "1"), - os.stat(test_support.TESTFN + "1") + os.stat(support.TESTFN + "1"), + os.stat(support.TESTFN + "1") ), True ) @@ -298,22 +298,22 @@ class PosixPathTest(unittest.TestCase): # inode information and thus, that samefile() doesn't work if hasattr(os, "symlink"): if hasattr(os, "symlink"): - os.symlink(test_support.TESTFN + "1", test_support.TESTFN + "2") + os.symlink(support.TESTFN + "1", support.TESTFN + "2") self.assertIs( posixpath.samestat( - os.stat(test_support.TESTFN + "1"), - os.stat(test_support.TESTFN + "2") + os.stat(support.TESTFN + "1"), + os.stat(support.TESTFN + "2") ), True ) - os.remove(test_support.TESTFN + "2") - f = open(test_support.TESTFN + "2", "wb") + os.remove(support.TESTFN + "2") + f = open(support.TESTFN + "2", "wb") f.write(b"bar") f.close() self.assertIs( posixpath.samestat( - os.stat(test_support.TESTFN + "1"), - os.stat(test_support.TESTFN + "2") + os.stat(support.TESTFN + "1"), + os.stat(support.TESTFN + "2") ), False ) @@ -399,7 +399,7 @@ class PosixPathTest(unittest.TestCase): os.symlink(ABSTFN+"1", ABSTFN) self.assertEqual(realpath(ABSTFN), ABSTFN+"1") finally: - test_support.unlink(ABSTFN) + support.unlink(ABSTFN) def test_realpath_symlink_loops(self): # Bug #930024, return the path unchanged if we get into an infinite @@ -419,9 +419,9 @@ class PosixPathTest(unittest.TestCase): self.assertEqual(realpath(basename(ABSTFN)), ABSTFN) finally: os.chdir(old_path) - test_support.unlink(ABSTFN) - test_support.unlink(ABSTFN+"1") - test_support.unlink(ABSTFN+"2") + support.unlink(ABSTFN) + support.unlink(ABSTFN+"1") + support.unlink(ABSTFN+"2") def test_realpath_resolve_parents(self): # We also need to resolve any symlinks in the parents of a relative @@ -438,7 +438,7 @@ class PosixPathTest(unittest.TestCase): self.assertEqual(realpath("a"), ABSTFN + "/y/a") finally: os.chdir(old_path) - test_support.unlink(ABSTFN + "/k") + support.unlink(ABSTFN + "/k") safe_rmdir(ABSTFN + "/y") safe_rmdir(ABSTFN) @@ -464,7 +464,7 @@ class PosixPathTest(unittest.TestCase): self.assertEqual(realpath(basename(ABSTFN) + "/link-y/.."), ABSTFN + "/k") finally: os.chdir(old_path) - test_support.unlink(ABSTFN + "/link-y") + support.unlink(ABSTFN + "/link-y") safe_rmdir(ABSTFN + "/k/y") safe_rmdir(ABSTFN + "/k") safe_rmdir(ABSTFN) @@ -485,7 +485,7 @@ class PosixPathTest(unittest.TestCase): self.assertEqual(realpath(base + "link/k"), ABSTFN + "/k") finally: os.chdir(old_path) - test_support.unlink(ABSTFN + "link") + support.unlink(ABSTFN + "link") safe_rmdir(ABSTFN + "/k") safe_rmdir(ABSTFN) @@ -506,7 +506,7 @@ class PosixPathTest(unittest.TestCase): os.getcwd = real_getcwd def test_main(): - test_support.run_unittest(PosixPathTest) + support.run_unittest(PosixPathTest) if __name__=="__main__": test_main() diff --git a/Lib/test/test_pow.py b/Lib/test/test_pow.py index 9b358f1..859c373 100644 --- a/Lib/test/test_pow.py +++ b/Lib/test/test_pow.py @@ -1,4 +1,4 @@ -import test.test_support, unittest +import test.support, unittest class PowTest(unittest.TestCase): @@ -123,7 +123,7 @@ class PowTest(unittest.TestCase): eq(expected, 1.0) # else we didn't push fiveto to evenness def test_main(): - test.test_support.run_unittest(PowTest) + test.support.run_unittest(PowTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_pprint.py b/Lib/test/test_pprint.py index ed35287..54c0c57 100644 --- a/Lib/test/test_pprint.py +++ b/Lib/test/test_pprint.py @@ -1,5 +1,5 @@ import pprint -import test.test_support +import test.support import unittest import test.test_set @@ -411,7 +411,7 @@ class DottedPrettyPrinter(pprint.PrettyPrinter): def test_main(): - test.test_support.run_unittest(QueryTestCase) + test.support.run_unittest(QueryTestCase) if __name__ == "__main__": diff --git a/Lib/test/test_print.py b/Lib/test/test_print.py index 58ca069..f157bc7 100644 --- a/Lib/test/test_print.py +++ b/Lib/test/test_print.py @@ -6,7 +6,7 @@ from __future__ import print_function import unittest -from test import test_support +from test import support import sys try: @@ -62,7 +62,7 @@ class TestPrint(unittest.TestCase): end is not NotDefined, file is not NotDefined)] - with test_support.captured_stdout() as t: + with support.captured_stdout() as t: fn(args, sep, end, file) self.assertEqual(t.getvalue(), expected) @@ -113,7 +113,7 @@ class TestPrint(unittest.TestCase): self.assertRaises(AttributeError, print, '', file='') def test_main(): - test_support.run_unittest(TestPrint) + support.run_unittest(TestPrint) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_profile.py b/Lib/test/test_profile.py index 9fea434..84167dd 100755 --- a/Lib/test/test_profile.py +++ b/Lib/test/test_profile.py @@ -6,7 +6,7 @@ import pstats import unittest from difflib import unified_diff from io import StringIO -from test.test_support import run_unittest +from test.support import run_unittest import profile from test.profilee import testfunc, timer diff --git a/Lib/test/test_profilehooks.py b/Lib/test/test_profilehooks.py index 6d6aa8e..296c997 100644 --- a/Lib/test/test_profilehooks.py +++ b/Lib/test/test_profilehooks.py @@ -2,7 +2,7 @@ import pprint import sys import unittest -from test import test_support +from test import support class TestGetProfile(unittest.TestCase): def setUp(self): @@ -357,7 +357,7 @@ def capture_events(callable, p=None): except TypeError: pass else: - raise test_support.TestFailed( + raise support.TestFailed( 'sys.setprofile() did not raise TypeError') if p is None: @@ -374,7 +374,7 @@ def show_events(callable): def test_main(): - test_support.run_unittest( + support.run_unittest( TestGetProfile, ProfileHookTestCase, ProfileSimulatorTestCase diff --git a/Lib/test/test_property.py b/Lib/test/test_property.py index 4b6e20c..c957ec2 100644 --- a/Lib/test/test_property.py +++ b/Lib/test/test_property.py @@ -2,7 +2,7 @@ # more tests are in test_descr import unittest -from test.test_support import run_unittest +from test.support import run_unittest class PropertyBase(Exception): pass diff --git a/Lib/test/test_pstats.py b/Lib/test/test_pstats.py index 660316b..095123d 100644 --- a/Lib/test/test_pstats.py +++ b/Lib/test/test_pstats.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support import pstats @@ -17,7 +17,7 @@ class AddCallersTestCase(unittest.TestCase): def test_main(): - test_support.run_unittest( + support.run_unittest( AddCallersTestCase ) diff --git a/Lib/test/test_pty.py b/Lib/test/test_pty.py index 58a3041..f62fc99 100644 --- a/Lib/test/test_pty.py +++ b/Lib/test/test_pty.py @@ -4,7 +4,7 @@ import pty import os import sys import signal -from test.test_support import verbose, TestSkipped, run_unittest +from test.support import verbose, TestSkipped, run_unittest import unittest TEST_STRING_1 = "I wish to buy a fish license.\n" diff --git a/Lib/test/test_pwd.py b/Lib/test/test_pwd.py index 19187a3..b5a5de7 100644 --- a/Lib/test/test_pwd.py +++ b/Lib/test/test_pwd.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support import pwd @@ -91,7 +91,7 @@ class PwdTest(unittest.TestCase): self.assertRaises(KeyError, pwd.getpwuid, fakeuid) def test_main(): - test_support.run_unittest(PwdTest) + support.run_unittest(PwdTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_pyclbr.py b/Lib/test/test_pyclbr.py index 57ede89..bcc16df 100644 --- a/Lib/test/test_pyclbr.py +++ b/Lib/test/test_pyclbr.py @@ -2,7 +2,7 @@ Test cases for pyclbr.py Nick Mathewson ''' -from test.test_support import run_unittest +from test.support import run_unittest import sys from types import FunctionType, MethodType, BuiltinFunctionType import pyclbr diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py index ba37ec1..cc4a096 100644 --- a/Lib/test/test_pydoc.py +++ b/Lib/test/test_pydoc.py @@ -1,4 +1,4 @@ -from test import test_support +from test import support import unittest import pydoc @@ -19,7 +19,7 @@ class TestDescriptions(unittest.TestCase): in pydoc.render_doc(c)) def test_main(): - test_support.run_unittest(TestDescriptions) + support.run_unittest(TestDescriptions) if __name__ == "__main__": unittest.main() diff --git a/Lib/test/test_pyexpat.py b/Lib/test/test_pyexpat.py index 9fda72d..c252134 100644 --- a/Lib/test/test_pyexpat.py +++ b/Lib/test/test_pyexpat.py @@ -8,7 +8,7 @@ import unittest import pyexpat from xml.parsers import expat -from test.test_support import sortdict, run_unittest +from test.support import sortdict, run_unittest class SetAttributeTest(unittest.TestCase): diff --git a/Lib/test/test_queue.py b/Lib/test/test_queue.py index df7b7e3..6303117 100644 --- a/Lib/test/test_queue.py +++ b/Lib/test/test_queue.py @@ -5,7 +5,7 @@ import sys import threading import time import unittest -from test import test_support +from test import support QUEUE_SIZE = 5 @@ -318,7 +318,7 @@ class FailingQueueTest(unittest.TestCase, BlockingTestMixin): def test_main(): - test_support.run_unittest(QueueTest, LifoQueueTest, PriorityQueueTest, + support.run_unittest(QueueTest, LifoQueueTest, PriorityQueueTest, FailingQueueTest) diff --git a/Lib/test/test_quopri.py b/Lib/test/test_quopri.py index b9ad65b..2c52a3c 100644 --- a/Lib/test/test_quopri.py +++ b/Lib/test/test_quopri.py @@ -1,4 +1,4 @@ -from test import test_support +from test import support import unittest import sys, os, io, subprocess @@ -199,7 +199,7 @@ zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz''') self.assertEqual(cout.splitlines(), p.splitlines()) def test_main(): - test_support.run_unittest(QuopriTestCase) + support.run_unittest(QuopriTestCase) if __name__ == "__main__": diff --git a/Lib/test/test_raise.py b/Lib/test/test_raise.py index 27a5cbc..89e2190 100644 --- a/Lib/test/test_raise.py +++ b/Lib/test/test_raise.py @@ -3,7 +3,7 @@ """Tests for the raise statement.""" -from test import test_support +from test import support import sys import types import unittest @@ -156,7 +156,7 @@ class TestRemovedFunctionality(unittest.TestCase): def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py index c02eb09..04c49fa 100644 --- a/Lib/test/test_random.py +++ b/Lib/test/test_random.py @@ -6,7 +6,7 @@ import time import pickle import warnings from math import log, exp, sqrt, pi -from test import test_support +from test import support class TestBasicOps(unittest.TestCase): # Superclass with tests common to all generators. @@ -118,7 +118,7 @@ class TestBasicOps(unittest.TestCase): ("randv2_64.pck", 866), ("randv3.pck", 343)] for file, value in files: - f = open(test_support.findfile(file),"rb") + f = open(support.findfile(file),"rb") r = pickle.load(f) f.close() self.assertEqual(r.randrange(1000), value) @@ -474,14 +474,14 @@ def test_main(verbose=None): else: testclasses.append(SystemRandom_TestBasicOps) - test_support.run_unittest(*testclasses) + support.run_unittest(*testclasses) # verify reference counting import sys if verbose and hasattr(sys, "gettotalrefcount"): counts = [None] * 5 for i in range(len(counts)): - test_support.run_unittest(*testclasses) + support.run_unittest(*testclasses) counts[i] = sys.gettotalrefcount() print(counts) diff --git a/Lib/test/test_range.py b/Lib/test/test_range.py index dedf007..1fd8f1d 100644 --- a/Lib/test/test_range.py +++ b/Lib/test/test_range.py @@ -1,6 +1,6 @@ # Python test set -- built-in functions -import test.test_support, unittest +import test.support, unittest import sys import warnings @@ -62,7 +62,7 @@ class RangeTest(unittest.TestCase): self.assertEqual(repr(range(1, 2, 3)), 'range(1, 2, 3)') def test_main(): - test.test_support.run_unittest(RangeTest) + test.support.run_unittest(RangeTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py index 11677f3..0b023c2 100644 --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -1,7 +1,7 @@ import sys sys.path = ['.'] + sys.path -from test.test_support import verbose, run_unittest, catch_warning +from test.support import verbose, run_unittest, catch_warning import re from re import Scanner import sys, os, traceback diff --git a/Lib/test/test_reprlib.py b/Lib/test/test_reprlib.py index 442c048..8bd0ccf 100644 --- a/Lib/test/test_reprlib.py +++ b/Lib/test/test_reprlib.py @@ -8,7 +8,7 @@ import os import shutil import unittest -from test.test_support import run_unittest +from test.support import run_unittest from reprlib import repr as r # Don't shadow builtin repr from reprlib import Repr diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py index b66caf8..7063ff9 100644 --- a/Lib/test/test_resource.py +++ b/Lib/test/test_resource.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support import resource import time @@ -47,7 +47,7 @@ class ResourceTest(unittest.TestCase): limit_set = True except ValueError: limit_set = False - f = open(test_support.TESTFN, "wb") + f = open(support.TESTFN, "wb") try: f.write(b"X" * 1024) try: @@ -73,7 +73,7 @@ class ResourceTest(unittest.TestCase): finally: if limit_set: resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max)) - test_support.unlink(test_support.TESTFN) + support.unlink(support.TESTFN) def test_fsize_toobig(self): # Be sure that setrlimit is checking for really large values @@ -104,7 +104,7 @@ class ResourceTest(unittest.TestCase): pass def test_main(verbose=None): - test_support.run_unittest(ResourceTest) + support.run_unittest(ResourceTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_rfc822.py b/Lib/test/test_rfc822.py index 1f5dd64..d2883e9 100644 --- a/Lib/test/test_rfc822.py +++ b/Lib/test/test_rfc822.py @@ -1,6 +1,6 @@ import rfc822 import unittest -from test import test_support +from test import support try: from io import StringIO @@ -249,7 +249,7 @@ A test message. def test_main(): - test_support.run_unittest(MessageTestCase) + support.run_unittest(MessageTestCase) if __name__ == "__main__": diff --git a/Lib/test/test_richcmp.py b/Lib/test/test_richcmp.py index 7b6f9be..30dac8f 100644 --- a/Lib/test/test_richcmp.py +++ b/Lib/test/test_richcmp.py @@ -1,7 +1,7 @@ # Tests for rich comparisons import unittest -from test import test_support +from test import support import operator @@ -29,7 +29,7 @@ class Number: return self.x >= other def __cmp__(self, other): - raise test_support.TestFailed("Number.__cmp__() should not be called") + raise support.TestFailed("Number.__cmp__() should not be called") def __repr__(self): return "Number(%r)" % (self.x, ) @@ -55,7 +55,7 @@ class Vector: raise TypeError("Vectors cannot be used in Boolean contexts") def __cmp__(self, other): - raise test_support.TestFailed("Vector.__cmp__() should not be called") + raise support.TestFailed("Vector.__cmp__() should not be called") def __repr__(self): return "Vector(%r)" % (self.data, ) @@ -387,11 +387,11 @@ class HashableTest(unittest.TestCase): self.assertEquals(str(e), "unhashable type: 'DumbEqualityWithoutHash'") else: - raise test_support.TestFailed("Should not be here") + raise support.TestFailed("Should not be here") def test_main(): - test_support.run_unittest(VectorTest, NumberTest, MiscTest, DictTest, ListTest, HashableTest) + support.run_unittest(VectorTest, NumberTest, MiscTest, DictTest, ListTest, HashableTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_robotparser.py b/Lib/test/test_robotparser.py index ad66b69..4e530f0 100644 --- a/Lib/test/test_robotparser.py +++ b/Lib/test/test_robotparser.py @@ -1,6 +1,6 @@ import unittest, robotparser import io -from test import test_support +from test import support class RobotTestCase(unittest.TestCase): def __init__(self, index, parser, url, good, agent): @@ -137,7 +137,7 @@ RobotTest(7, doc, good, bad) class TestCase(unittest.TestCase): def runTest(self): - test_support.requires('network') + support.requires('network') # whole site is password-protected. url = 'http://mueblesmoraleda.com' parser = robotparser.RobotFileParser() @@ -146,9 +146,9 @@ class TestCase(unittest.TestCase): self.assertEqual(parser.can_fetch("*", url+"/robots.txt"), False) def test_main(): - test_support.run_unittest(tests) + support.run_unittest(tests) TestCase().run() if __name__=='__main__': - test_support.Verbose = 1 + support.Verbose = 1 test_main() diff --git a/Lib/test/test_runpy.py b/Lib/test/test_runpy.py index ffa36dc..43691cb 100644 --- a/Lib/test/test_runpy.py +++ b/Lib/test/test_runpy.py @@ -4,7 +4,7 @@ import os import os.path import sys import tempfile -from test.test_support import verbose, run_unittest, forget +from test.support import verbose, run_unittest, forget from runpy import _run_code, _run_module_code, run_module # Note: This module can't safely test _run_module_as_main as it diff --git a/Lib/test/test_sax.py b/Lib/test/test_sax.py index eb79581..5f1a48e 100644 --- a/Lib/test/test_sax.py +++ b/Lib/test/test_sax.py @@ -13,7 +13,7 @@ from xml.sax.saxutils import XMLGenerator, escape, unescape, quoteattr, \ from xml.sax.expatreader import create_parser from xml.sax.xmlreader import InputSource, AttributesImpl, AttributesNSImpl from io import StringIO -from test.test_support import findfile, run_unittest +from test.support import findfile, run_unittest import unittest import os diff --git a/Lib/test/test_scope.py b/Lib/test/test_scope.py index c18445d..a3f1d4a 100644 --- a/Lib/test/test_scope.py +++ b/Lib/test/test_scope.py @@ -1,5 +1,5 @@ import unittest -from test.test_support import check_syntax_error, run_unittest +from test.support import check_syntax_error, run_unittest import warnings warnings.filterwarnings("ignore", r"import \*", SyntaxWarning, "") diff --git a/Lib/test/test_select.py b/Lib/test/test_select.py index f4032d1..a463868 100644 --- a/Lib/test/test_select.py +++ b/Lib/test/test_select.py @@ -1,4 +1,4 @@ -from test import test_support +from test import support import unittest import select import os @@ -21,23 +21,23 @@ class SelectTestCase(unittest.TestCase): def test_select(self): if sys.platform[:3] in ('win', 'mac', 'os2', 'riscos'): - if test_support.verbose: + if support.verbose: print("Can't test select easily on", sys.platform) return cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 1; done' p = os.popen(cmd, 'r') for tout in (0, 1, 2, 4, 8, 16) + (None,)*10: - if test_support.verbose: + if support.verbose: print('timeout =', tout) rfd, wfd, xfd = select.select([p], [], [], tout) if (rfd, wfd, xfd) == ([], [], []): continue if (rfd, wfd, xfd) == ([p], [], []): line = p.readline() - if test_support.verbose: + if support.verbose: print(repr(line)) if not line: - if test_support.verbose: + if support.verbose: print('EOF') break continue @@ -45,8 +45,8 @@ class SelectTestCase(unittest.TestCase): p.close() def test_main(): - test_support.run_unittest(SelectTestCase) - test_support.reap_children() + support.run_unittest(SelectTestCase) + support.reap_children() if __name__ == "__main__": test_main() diff --git a/Lib/test/test_set.py b/Lib/test/test_set.py index 44a45af..d05df3f 100644 --- a/Lib/test/test_set.py +++ b/Lib/test/test_set.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support from weakref import proxy import operator import copy @@ -288,14 +288,14 @@ class TestJointOps(unittest.TestCase): s = self.thetype([w]) w.value = s try: - fo = open(test_support.TESTFN, "w") + fo = open(support.TESTFN, "w") fo.write(str(s)) fo.close() - fo = open(test_support.TESTFN, "r") + fo = open(support.TESTFN, "r") self.assertEqual(fo.read(), repr(s)) finally: fo.close() - test_support.unlink(test_support.TESTFN) + support.unlink(support.TESTFN) def test_do_not_rehash_dict_keys(self): n = 10 @@ -672,14 +672,14 @@ class TestBasicOps(unittest.TestCase): def test_print(self): try: - fo = open(test_support.TESTFN, "w") + fo = open(support.TESTFN, "w") fo.write(str(self.set)) fo.close() - fo = open(test_support.TESTFN, "r") + fo = open(support.TESTFN, "r") self.assertEqual(fo.read(), repr(self.set)) finally: fo.close() - test_support.unlink(test_support.TESTFN) + support.unlink(support.TESTFN) def test_length(self): self.assertEqual(len(self.set), self.length) @@ -1752,14 +1752,14 @@ def test_main(verbose=None): TestGraphs, ) - test_support.run_unittest(*test_classes) + support.run_unittest(*test_classes) # 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_setcomps.py b/Lib/test/test_setcomps.py index f382293..fb7cde0 100644 --- a/Lib/test/test_setcomps.py +++ b/Lib/test/test_setcomps.py @@ -133,16 +133,16 @@ __test__ = {'doctests' : doctests} def test_main(verbose=None): import sys - from test import test_support + from test import support from test import test_setcomps - test_support.run_doctest(test_setcomps, verbose) + support.run_doctest(test_setcomps, verbose) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in range(len(counts)): - test_support.run_doctest(test_setcomps, verbose) + support.run_doctest(test_setcomps, verbose) gc.collect() counts[i] = sys.gettotalrefcount() print(counts) diff --git a/Lib/test/test_sgmllib.py b/Lib/test/test_sgmllib.py index 374b921..6015878 100644 --- a/Lib/test/test_sgmllib.py +++ b/Lib/test/test_sgmllib.py @@ -2,7 +2,7 @@ import pprint import re import sgmllib import unittest -from test import test_support +from test import support class EventCollector(sgmllib.SGMLParser): @@ -365,7 +365,7 @@ DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01//EN' # Just verify this code doesn't cause a hang. CHUNK = 1024 # increasing this to 8212 makes the problem go away - f = open(test_support.findfile('sgml_input.html'), encoding="latin-1") + f = open(support.findfile('sgml_input.html'), encoding="latin-1") fp = sgmllib.SGMLParser() while 1: data = f.read(CHUNK) @@ -431,7 +431,7 @@ DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01//EN' def test_main(): - test_support.run_unittest(SGMLParserTestCase) + support.run_unittest(SGMLParserTestCase) if __name__ == "__main__": diff --git a/Lib/test/test_shelve.py b/Lib/test/test_shelve.py index 6d917ff..5fb4641 100644 --- a/Lib/test/test_shelve.py +++ b/Lib/test/test_shelve.py @@ -1,7 +1,7 @@ import unittest import shelve import glob -from test import test_support +from test import support from collections import MutableMapping from test.test_anydbm import dbm_iterator @@ -45,7 +45,7 @@ class TestCase(unittest.TestCase): def tearDown(self): for f in glob.glob(self.fn+"*"): - test_support.unlink(f) + support.unlink(f) def test_ascii_file_shelf(self): s = shelve.open(self.fn, protocol=0) @@ -133,7 +133,7 @@ class TestShelveBase(mapping_tests.BasicTestMappingProtocol): self._db = [] if not self._in_mem: for f in glob.glob(self.fn+"*"): - test_support.unlink(f) + support.unlink(f) class TestAsciiFileShelve(TestShelveBase): _args={'protocol':0} @@ -156,7 +156,7 @@ class TestProto2MemShelve(TestShelveBase): def test_main(): for module in dbm_iterator(): - test_support.run_unittest( + support.run_unittest( TestAsciiFileShelve, TestBinaryFileShelve, TestProto2FileShelve, diff --git a/Lib/test/test_shlex.py b/Lib/test/test_shlex.py index b18155e..1685938 100644 --- a/Lib/test/test_shlex.py +++ b/Lib/test/test_shlex.py @@ -3,7 +3,7 @@ import unittest import os, sys, io import shlex -from test import test_support +from test import support # The original test data set was from shellwords, by Hartmut Goebel. @@ -181,7 +181,7 @@ if not getattr(shlex, "split", None): delattr(ShlexTest, methname) def test_main(): - test_support.run_unittest(ShlexTest) + support.run_unittest(ShlexTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py index 2a316b2..2e680a9 100644 --- a/Lib/test/test_shutil.py +++ b/Lib/test/test_shutil.py @@ -7,8 +7,8 @@ import sys import stat import os import os.path -from test import test_support -from test.test_support import TESTFN +from test import support +from test.support import TESTFN class TestShutil(unittest.TestCase): def test_rmtree_errors(self): @@ -267,7 +267,7 @@ class TestMove(unittest.TestCase): def test_main(): - test_support.run_unittest(TestShutil, TestMove) + support.run_unittest(TestShutil, TestMove) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py index 339cec2..b8ac2cc 100644 --- a/Lib/test/test_signal.py +++ b/Lib/test/test_signal.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support from contextlib import closing, nested import gc import pickle @@ -10,7 +10,7 @@ import traceback import sys, os, time, errno if sys.platform[:3] in ('win', 'os2') or sys.platform == 'riscos': - raise test_support.TestSkipped("Can't test signal on %s" % \ + raise support.TestSkipped("Can't test signal on %s" % \ sys.platform) @@ -53,13 +53,13 @@ class InterProcessSignalTests(unittest.TestCase): def handlerA(self, signum, frame): self.a_called = True - if test_support.verbose: + if support.verbose: print("handlerA invoked from signal %s at:\n%s" % ( signum, self.format_frame(frame, limit=1))) def handlerB(self, signum, frame): self.b_called = True - if test_support.verbose: + if support.verbose: print ("handlerB invoked from signal %s at:\n%s" % ( signum, self.format_frame(frame, limit=1))) raise HandlerBCalled(signum, self.format_frame(frame)) @@ -88,7 +88,7 @@ class InterProcessSignalTests(unittest.TestCase): # Let the sub-processes know who to send signals to. pid = os.getpid() - if test_support.verbose: + if support.verbose: print("test runner's pid is", pid) child = ignoring_eintr(subprocess.Popen, ['kill', '-HUP', str(pid)]) @@ -113,7 +113,7 @@ class InterProcessSignalTests(unittest.TestCase): except HandlerBCalled: self.assertTrue(self.b_called) self.assertFalse(self.a_called) - if test_support.verbose: + if support.verbose: print("HandlerBCalled exception caught") child = ignoring_eintr(subprocess.Popen, ['kill', '-USR2', str(pid)]) @@ -130,7 +130,7 @@ class InterProcessSignalTests(unittest.TestCase): # may return early. time.sleep(1) except KeyboardInterrupt: - if test_support.verbose: + if support.verbose: print("KeyboardInterrupt (the alarm() went off)") except: self.fail("Some other exception woke us from pause: %s" % @@ -309,7 +309,7 @@ class ItimerTest(unittest.TestCase): def sig_alrm(self, *args): self.hndl_called = True - if test_support.verbose: + if support.verbose: print("SIGALRM handler invoked", args) def sig_vtalrm(self, *args): @@ -322,19 +322,19 @@ class ItimerTest(unittest.TestCase): elif self.hndl_count == 3: # disable ITIMER_VIRTUAL, this function shouldn't be called anymore signal.setitimer(signal.ITIMER_VIRTUAL, 0) - if test_support.verbose: + if support.verbose: print("last SIGVTALRM handler call") self.hndl_count += 1 - if test_support.verbose: + if support.verbose: print("SIGVTALRM handler invoked", args) def sig_prof(self, *args): self.hndl_called = True signal.setitimer(signal.ITIMER_PROF, 0) - if test_support.verbose: + if support.verbose: print("SIGPROF handler invoked", args) def test_itimer_exc(self): @@ -349,7 +349,7 @@ class ItimerTest(unittest.TestCase): def test_itimer_real(self): self.itimer = signal.ITIMER_REAL signal.setitimer(self.itimer, 1.0) - if test_support.verbose: + if support.verbose: print("\ncall pause()...") signal.pause() @@ -384,7 +384,7 @@ class ItimerTest(unittest.TestCase): self.assertEqual(self.hndl_called, True) def test_main(): - test_support.run_unittest(BasicSignalTests, InterProcessSignalTests, + support.run_unittest(BasicSignalTests, InterProcessSignalTests, WakeupSignalTests, SiginterruptTest, ItimerTest) diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py index a13751c..3f93a38 100644 --- a/Lib/test/test_site.py +++ b/Lib/test/test_site.py @@ -5,7 +5,7 @@ executing have not been removed. """ import unittest -from test.test_support import TestSkipped, run_unittest, TESTFN +from test.support import TestSkipped, run_unittest, TESTFN import builtins import os import sys diff --git a/Lib/test/test_slice.py b/Lib/test/test_slice.py index 20d2027..e619746 100644 --- a/Lib/test/test_slice.py +++ b/Lib/test/test_slice.py @@ -1,7 +1,7 @@ # tests for slice objects; in particular the indices method. import unittest -from test import test_support +from test import support from pickle import loads, dumps import sys @@ -115,7 +115,7 @@ class SliceTest(unittest.TestCase): self.assertNotEqual(id(s), id(t)) def test_main(): - test_support.run_unittest(SliceTest) + support.run_unittest(SliceTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py index 9dc672d..3d38d89 100644 --- a/Lib/test/test_smtplib.py +++ b/Lib/test/test_smtplib.py @@ -10,9 +10,9 @@ import time import select from unittest import TestCase -from test import test_support +from test import support -HOST = test_support.HOST +HOST = support.HOST def server(evt, buf, serv): serv.listen(5) @@ -42,7 +42,7 @@ class GeneralTests(TestCase): self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(15) - self.port = test_support.bind_port(self.sock) + self.port = support.bind_port(self.sock) servargs = (self.evt, b"220 Hola mundo\n", self.sock) threading.Thread(target=server, args=servargs).start() self.evt.wait() @@ -142,7 +142,7 @@ class DebuggingServerTests(TestCase): self.serv_evt = threading.Event() self.client_evt = threading.Event() - self.port = test_support.find_unused_port() + self.port = support.find_unused_port() self.serv = smtpd.DebuggingServer((HOST, self.port), ('nowhere', -1)) serv_args = (self.serv, self.serv_evt, self.client_evt) threading.Thread(target=debugging_server, args=serv_args).start() @@ -250,7 +250,7 @@ class BadHELOServerTests(TestCase): self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(15) - self.port = test_support.bind_port(self.sock) + self.port = support.bind_port(self.sock) servargs = (self.evt, b"199 no hello for you!\n", self.sock) threading.Thread(target=server, args=servargs).start() self.evt.wait() @@ -327,7 +327,7 @@ class SMTPSimTests(TestCase): def setUp(self): self.serv_evt = threading.Event() self.client_evt = threading.Event() - self.port = test_support.find_unused_port() + self.port = support.find_unused_port() self.serv = SimSMTPServer((HOST, self.port), ('nowhere', -1)) serv_args = (self.serv, self.serv_evt, self.client_evt) threading.Thread(target=debugging_server, args=serv_args).start() @@ -401,7 +401,7 @@ class SMTPSimTests(TestCase): def test_main(verbose=None): - test_support.run_unittest(GeneralTests, DebuggingServerTests, + support.run_unittest(GeneralTests, DebuggingServerTests, NonConnectingTests, BadHELOServerTests, SMTPSimTests) diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index ab860dd..349548f 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -1,7 +1,7 @@ #!/usr/bin/env python import unittest -from test import test_support +from test import support import errno import socket @@ -16,14 +16,14 @@ import array from weakref import proxy import signal -HOST = test_support.HOST +HOST = support.HOST MSG = b'Michael Gilfix was here\n' class SocketTCPTest(unittest.TestCase): def setUp(self): self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.port = test_support.bind_port(self.serv) + self.port = support.bind_port(self.serv) self.serv.listen(1) def tearDown(self): @@ -34,7 +34,7 @@ class SocketUDPTest(unittest.TestCase): def setUp(self): self.serv = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - self.port = test_support.bind_port(self.serv) + self.port = support.bind_port(self.serv) def tearDown(self): self.serv.close() @@ -898,7 +898,7 @@ class BasicTCPTest2(NetworkConnectionTest, BasicTCPTest): class NetworkConnectionNoServer(unittest.TestCase): def testWithoutServer(self): - port = test_support.find_unused_port() + port = support.find_unused_port() self.failUnlessRaises( socket.error, lambda: socket.create_connection((HOST, port)) @@ -1145,7 +1145,7 @@ def isTipcAvailable(): for line in f: if line.startswith("tipc "): return True - if test_support.verbose: + if support.verbose: print("TIPC module is not loaded, please 'sudo modprobe tipc'") return False @@ -1229,9 +1229,9 @@ def test_main(): tests.append(TIPCTest) tests.append(TIPCThreadableTest) - thread_info = test_support.threading_setup() - test_support.run_unittest(*tests) - test_support.threading_cleanup(*thread_info) + thread_info = support.threading_setup() + support.run_unittest(*tests) + support.threading_cleanup(*thread_info) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py index b6bb0f7..5b733ae 100644 --- a/Lib/test/test_socketserver.py +++ b/Lib/test/test_socketserver.py @@ -15,14 +15,14 @@ import time import unittest import socketserver -import test.test_support -from test.test_support import reap_children, verbose, TestSkipped -from test.test_support import TESTFN as TEST_FILE +import test.support +from test.support import reap_children, verbose, TestSkipped +from test.support import TESTFN as TEST_FILE -test.test_support.requires("network") +test.support.requires("network") TEST_STR = b"hello world\n" -HOST = test.test_support.HOST +HOST = test.support.HOST HAVE_UNIX_SOCKETS = hasattr(socket, "AF_UNIX") HAVE_FORKING = hasattr(os, "fork") and os.name != "os2" @@ -249,7 +249,7 @@ def test_main(): # If the import lock is held, the threads will hang raise TestSkipped("can't run when import lock is held") - test.test_support.run_unittest(SocketServerTest) + test.support.run_unittest(SocketServerTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_sort.py b/Lib/test/test_sort.py index 8301c31..8b108d5 100644 --- a/Lib/test/test_sort.py +++ b/Lib/test/test_sort.py @@ -1,9 +1,9 @@ -from test import test_support +from test import support import random import sys import unittest -verbose = test_support.verbose +verbose = support.verbose nerrors = 0 def CmpToKey(mycmp): @@ -261,14 +261,14 @@ def test_main(verbose=None): TestBugs, ) - test_support.run_unittest(*test_classes) + support.run_unittest(*test_classes) # 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_sqlite.py b/Lib/test/test_sqlite.py index 945dd51..b8a9acf 100644 --- a/Lib/test/test_sqlite.py +++ b/Lib/test/test_sqlite.py @@ -1,4 +1,4 @@ -from test.test_support import run_unittest, TestSkipped +from test.support import run_unittest, TestSkipped try: import _sqlite3 diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py index 59bf57d..4f884f0 100644 --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -2,7 +2,7 @@ import sys import unittest -from test import test_support +from test import support import socket import select import errno @@ -25,27 +25,27 @@ try: except ImportError: skip_expected = True -HOST = test_support.HOST +HOST = support.HOST CERTFILE = None SVN_PYTHON_ORG_ROOT_CERT = None def handle_error(prefix): exc_format = ' '.join(traceback.format_exception(*sys.exc_info())) - if test_support.verbose: + if support.verbose: sys.stdout.write(prefix + exc_format) class BasicTests(unittest.TestCase): def testSSLconnect(self): - if not test_support.is_resource_enabled('network'): + if not support.is_resource_enabled('network'): return s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_NONE) s.connect(("svn.python.org", 443)) c = s.getpeercert() if c: - raise test_support.TestFailed("Peer cert %s shouldn't be here!") + raise support.TestFailed("Peer cert %s shouldn't be here!") s.close() # this should fail because we have no verification certs @@ -69,7 +69,7 @@ class BasicTests(unittest.TestCase): def testRAND(self): v = ssl.RAND_status() - if test_support.verbose: + if support.verbose: sys.stdout.write("\n RAND_status is %d (%s)\n" % (v, (v and "sufficient randomness") or "insufficient randomness")) @@ -86,7 +86,7 @@ class BasicTests(unittest.TestCase): # provided solely for this test, to exercise the certificate # parsing code p = ssl._ssl._test_decode_cert(CERTFILE, False) - if test_support.verbose: + if support.verbose: sys.stdout.write("\n" + pprint.pformat(p) + "\n") def testDERtoPEM(self): @@ -96,7 +96,7 @@ class BasicTests(unittest.TestCase): p2 = ssl.DER_cert_to_PEM_cert(d1) d2 = ssl.PEM_cert_to_DER_cert(p2) if (d1 != d2): - raise test_support.TestFailed("PEM-to-DER or DER-to-PEM translation failed") + raise support.TestFailed("PEM-to-DER or DER-to-PEM translation failed") class NetworkedTests(unittest.TestCase): @@ -106,7 +106,7 @@ class NetworkedTests(unittest.TestCase): s.connect(("svn.python.org", 443)) c = s.getpeercert() if c: - raise test_support.TestFailed("Peer cert %s shouldn't be here!") + raise support.TestFailed("Peer cert %s shouldn't be here!") s.close() # this should fail because we have no verification certs @@ -126,7 +126,7 @@ class NetworkedTests(unittest.TestCase): try: s.connect(("svn.python.org", 443)) except ssl.SSLError as x: - raise test_support.TestFailed("Unexpected exception %s" % x) + raise support.TestFailed("Unexpected exception %s" % x) finally: s.close() @@ -151,14 +151,14 @@ class NetworkedTests(unittest.TestCase): else: raise s.close() - if test_support.verbose: + if support.verbose: sys.stdout.write("\nNeeded %d calls to do_handshake() to establish session.\n" % count) def testFetchServerCert(self): pem = ssl.get_server_certificate(("svn.python.org", 443)) if not pem: - raise test_support.TestFailed("No server certificate on svn.python.org:443!") + raise support.TestFailed("No server certificate on svn.python.org:443!") return @@ -166,15 +166,15 @@ class NetworkedTests(unittest.TestCase): pem = ssl.get_server_certificate(("svn.python.org", 443), ca_certs=CERTFILE) except ssl.SSLError as x: #should fail - if test_support.verbose: + if support.verbose: sys.stdout.write("%s\n" % x) else: - raise test_support.TestFailed("Got server certificate %s for svn.python.org!" % pem) + raise support.TestFailed("Got server certificate %s for svn.python.org!" % pem) pem = ssl.get_server_certificate(("svn.python.org", 443), ca_certs=SVN_PYTHON_ORG_ROOT_CERT) if not pem: - raise test_support.TestFailed("No server certificate on svn.python.org:443!") - if test_support.verbose: + raise support.TestFailed("No server certificate on svn.python.org:443!") + if support.verbose: sys.stdout.write("\nVerified certificate for svn.python.org:443 is\n%s\n" % pem) @@ -227,13 +227,13 @@ else: else: if self.server.certreqs == ssl.CERT_REQUIRED: cert = self.sslconn.getpeercert() - if test_support.verbose and self.server.chatty: + if support.verbose and self.server.chatty: sys.stdout.write(" client cert is " + pprint.pformat(cert) + "\n") cert_binary = self.sslconn.getpeercert(True) - if test_support.verbose and self.server.chatty: + if support.verbose and self.server.chatty: sys.stdout.write(" cert binary is " + str(len(cert_binary)) + " bytes\n") cipher = self.sslconn.cipher() - if test_support.verbose and self.server.chatty: + if support.verbose and self.server.chatty: sys.stdout.write(" server: connection cipher is now " + str(cipher) + "\n") return True @@ -269,19 +269,19 @@ else: self.running = False self.close() elif amsg.strip() == 'over': - if test_support.verbose and self.server.connectionchatty: + if support.verbose and self.server.connectionchatty: sys.stdout.write(" server: client closed connection\n") self.close() return elif (self.server.starttls_server and amsg.strip() == 'STARTTLS'): - if test_support.verbose and self.server.connectionchatty: + if support.verbose and self.server.connectionchatty: sys.stdout.write(" server: read STARTTLS from client, sending OK...\n") self.write("OK\n".encode("ASCII", "strict")) if not self.wrap_conn(): return else: - if (test_support.verbose and + if (support.verbose and self.server.connectionchatty): ctype = (self.sslconn and "encrypted") or "unencrypted" sys.stdout.write(" server: read %s (%s), sending back %s (%s)...\n" @@ -314,7 +314,7 @@ else: self.connectionchatty = connectionchatty self.starttls_server = starttls_server self.sock = socket.socket() - self.port = test_support.bind_port(self.sock) + self.port = support.bind_port(self.sock) self.flag = None self.active = False threading.Thread.__init__(self) @@ -334,7 +334,7 @@ else: while self.active: try: newconn, connaddr = self.sock.accept() - if test_support.verbose and self.chatty: + if support.verbose and self.chatty: sys.stdout.write(' server: new connection from ' + repr(connaddr) + '\n') handler = self.ConnectionHandler(self, newconn, connaddr) @@ -457,7 +457,7 @@ else: # we override this to suppress logging unless "verbose" - if test_support.verbose: + if support.verbose: sys.stdout.write(" server (%s:%d %s):\n [%s] %s\n" % (self.server.server_address, self.server.server_port, @@ -470,7 +470,7 @@ else: self.flag = None self.active = False self.RootedHTTPRequestHandler.root = os.path.split(CERTFILE)[0] - self.port = test_support.find_unused_port() + self.port = support.find_unused_port() self.server = self.HTTPSServer( (HOST, self.port), self.RootedHTTPRequestHandler, certfile) threading.Thread.__init__(self) @@ -522,7 +522,7 @@ else: def handle_read(self): data = self.recv(1024) - if test_support.verbose: + if support.verbose: sys.stdout.write(" server: read %s from client\n" % repr(data)) if not data: self.close() @@ -530,7 +530,7 @@ else: self.send(str(data, 'ASCII', 'strict').lower().encode('ASCII', 'strict')) def handle_close(self): - if test_support.verbose: + if support.verbose: sys.stdout.write(" server: closed connection %s\n" % self.socket) def handle_error(self): @@ -546,7 +546,7 @@ else: def handle_accept(self): sock_obj, addr = self.accept() - if test_support.verbose: + if support.verbose: sys.stdout.write(" server: new connection from %s:%s\n" %addr) self.ConnectionHandler(sock_obj, self.certfile) @@ -556,7 +556,7 @@ else: def __init__(self, certfile): self.flag = None self.active = False - self.port = test_support.find_unused_port() + self.port = support.find_unused_port() self.server = self.EchoServer(self.port, certfile) threading.Thread.__init__(self) self.setDaemon(True) @@ -599,10 +599,10 @@ else: ssl_version=ssl.PROTOCOL_TLSv1) s.connect((HOST, server.port)) except ssl.SSLError as x: - if test_support.verbose: + if support.verbose: sys.stdout.write("\nSSLError is %s\n" % x) else: - raise test_support.TestFailed( + raise support.TestFailed( "Use of invalid cert should have failed!") finally: server.stop() @@ -635,28 +635,28 @@ else: ssl_version=client_protocol) s.connect((HOST, server.port)) except ssl.SSLError as x: - raise test_support.TestFailed("Unexpected SSL error: " + str(x)) + raise support.TestFailed("Unexpected SSL error: " + str(x)) except Exception as x: - raise test_support.TestFailed("Unexpected exception: " + str(x)) + raise support.TestFailed("Unexpected exception: " + str(x)) else: if connectionchatty: - if test_support.verbose: + if support.verbose: sys.stdout.write( " client: sending %s...\n" % (repr(indata))) s.write(indata.encode('ASCII', 'strict')) outdata = s.read() if connectionchatty: - if test_support.verbose: + if support.verbose: sys.stdout.write(" client: read %s\n" % repr(outdata)) outdata = str(outdata, 'ASCII', 'strict') if outdata != indata.lower(): - raise test_support.TestFailed( + raise support.TestFailed( "bad data <<%s>> (%d) received; expected <<%s>> (%d)\n" % (repr(outdata[:min(len(outdata),20)]), len(outdata), repr(indata[:min(len(indata),20)].lower()), len(indata))) s.write("over\n".encode("ASCII", "strict")) if connectionchatty: - if test_support.verbose: + if support.verbose: sys.stdout.write(" client: closing connection.\n") s.close() finally: @@ -677,7 +677,7 @@ else: certtype = "CERT_OPTIONAL" elif certsreqs == ssl.CERT_REQUIRED: certtype = "CERT_REQUIRED" - if test_support.verbose: + if support.verbose: formatstr = (expectedToWork and " %s->%s %s\n") or " {%s->%s} %s\n" sys.stdout.write(formatstr % (ssl.get_protocol_name(client_protocol), @@ -687,12 +687,12 @@ else: serverParamsTest(CERTFILE, server_protocol, certsreqs, CERTFILE, CERTFILE, client_protocol, chatty=False, connectionchatty=False) - except test_support.TestFailed: + except support.TestFailed: if expectedToWork: raise else: if not expectedToWork: - raise test_support.TestFailed( + raise support.TestFailed( "Client protocol %s succeeded with server protocol %s!" % (ssl.get_protocol_name(client_protocol), ssl.get_protocol_name(server_protocol))) @@ -702,7 +702,7 @@ else: def testEcho (self): - if test_support.verbose: + if support.verbose: sys.stdout.write("\n") serverParamsTest(CERTFILE, ssl.PROTOCOL_TLSv1, ssl.CERT_NONE, CERTFILE, CERTFILE, ssl.PROTOCOL_TLSv1, @@ -710,7 +710,7 @@ else: def testReadCert(self): - if test_support.verbose: + if support.verbose: sys.stdout.write("\n") s2 = socket.socket() server = ThreadedEchoServer(CERTFILE, @@ -732,30 +732,30 @@ else: ssl_version=ssl.PROTOCOL_SSLv23) s.connect((HOST, server.port)) except ssl.SSLError as x: - raise test_support.TestFailed( + raise support.TestFailed( "Unexpected SSL error: " + str(x)) except Exception as x: - raise test_support.TestFailed( + raise support.TestFailed( "Unexpected exception: " + str(x)) else: if not s: - raise test_support.TestFailed( + raise support.TestFailed( "Can't SSL-handshake with test server") cert = s.getpeercert() if not cert: - raise test_support.TestFailed( + raise support.TestFailed( "Can't get peer certificate.") cipher = s.cipher() - if test_support.verbose: + if support.verbose: sys.stdout.write(pprint.pformat(cert) + '\n') sys.stdout.write("Connection cipher is " + str(cipher) + '.\n') if 'subject' not in cert: - raise test_support.TestFailed( + raise support.TestFailed( "No subject field in certificate: %s." % pprint.pformat(cert)) if ((('organizationName', 'Python Software Foundation'),) not in cert['subject']): - raise test_support.TestFailed( + raise support.TestFailed( "Missing or invalid 'organizationName' field in certificate subject; " "should be 'Python Software Foundation'.") s.close() @@ -777,7 +777,7 @@ else: listener_ready = threading.Event() listener_gone = threading.Event() - port = test_support.find_unused_port() + port = support.find_unused_port() # `listener` runs in a thread. It opens a socket listening on # PORT, and sits in an accept() until the main thread connects. @@ -802,7 +802,7 @@ else: except IOError: pass else: - raise test_support.TestFailed( + raise support.TestFailed( 'connecting to closed SSL socket should have failed') t = threading.Thread(target=listener) @@ -811,7 +811,7 @@ else: t.join() def testProtocolSSL2(self): - if test_support.verbose: + if support.verbose: sys.stdout.write("\n") tryProtocolCombo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True) tryProtocolCombo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True, ssl.CERT_OPTIONAL) @@ -821,13 +821,13 @@ else: tryProtocolCombo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_TLSv1, False) def testProtocolSSL23(self): - if test_support.verbose: + if support.verbose: sys.stdout.write("\n") try: tryProtocolCombo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv2, True) - except test_support.TestFailed as x: + except support.TestFailed as x: # this fails on some older versions of OpenSSL (0.9.7l, for instance) - if test_support.verbose: + if support.verbose: sys.stdout.write( " SSL2 client to SSL23 server test unexpectedly failed:\n %s\n" % str(x)) @@ -844,7 +844,7 @@ else: tryProtocolCombo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, True, ssl.CERT_REQUIRED) def testProtocolSSL3(self): - if test_support.verbose: + if support.verbose: sys.stdout.write("\n") tryProtocolCombo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, True) tryProtocolCombo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, True, ssl.CERT_OPTIONAL) @@ -854,7 +854,7 @@ else: tryProtocolCombo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_TLSv1, False) def testProtocolTLS1(self): - if test_support.verbose: + if support.verbose: sys.stdout.write("\n") tryProtocolCombo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, True) tryProtocolCombo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, True, ssl.CERT_OPTIONAL) @@ -884,13 +884,13 @@ else: s.setblocking(1) s.connect((HOST, server.port)) except Exception as x: - raise test_support.TestFailed("Unexpected exception: " + str(x)) + raise support.TestFailed("Unexpected exception: " + str(x)) else: - if test_support.verbose: + if support.verbose: sys.stdout.write("\n") for indata in msgs: msg = indata.encode('ASCII', 'replace') - if test_support.verbose: + if support.verbose: sys.stdout.write( " client: sending %s...\n" % repr(msg)) if wrapped: @@ -901,7 +901,7 @@ else: outdata = s.recv(1024) if (indata == "STARTTLS" and str(outdata, 'ASCII', 'replace').strip().lower().startswith("ok")): - if test_support.verbose: + if support.verbose: msg = str(outdata, 'ASCII', 'replace') sys.stdout.write( " client: read %s from server, starting TLS...\n" @@ -910,11 +910,11 @@ else: wrapped = True else: - if test_support.verbose: + if support.verbose: msg = str(outdata, 'ASCII', 'replace') sys.stdout.write( " client: read %s from server\n" % repr(msg)) - if test_support.verbose: + if support.verbose: sys.stdout.write(" client: closing connection.\n") if wrapped: conn.write("over\n".encode("ASCII", "strict")) @@ -937,7 +937,7 @@ else: flag.wait() # try to connect try: - if test_support.verbose: + if support.verbose: sys.stdout.write('\n') d1 = open(CERTFILE, 'rb').read() d2 = '' @@ -948,33 +948,33 @@ else: dlen = f.info().getheader("content-length") if dlen and (int(dlen) > 0): d2 = f.read(int(dlen)) - if test_support.verbose: + if support.verbose: sys.stdout.write( " client: read %d bytes from remote server '%s'\n" % (len(d2), server)) f.close() except: msg = ''.join(traceback.format_exception(*sys.exc_info())) - if test_support.verbose: + if support.verbose: sys.stdout.write('\n' + msg) - raise test_support.TestFailed(msg) + raise support.TestFailed(msg) else: if not (d1 == d2): print("d1 is", len(d1), repr(d1)) print("d2 is", len(d2), repr(d2)) - raise test_support.TestFailed( + raise support.TestFailed( "Couldn't fetch data from HTTPS server") finally: - if test_support.verbose: + if support.verbose: sys.stdout.write('stopping server\n') server.stop() - if test_support.verbose: + if support.verbose: sys.stdout.write('joining thread\n') server.join() def testAsyncoreServer(self): - if test_support.verbose: + if support.verbose: sys.stdout.write("\n") indata="FOO\n" @@ -988,25 +988,25 @@ else: s = ssl.wrap_socket(socket.socket()) s.connect((HOST, server.port)) except ssl.SSLError as x: - raise test_support.TestFailed("Unexpected SSL error: " + str(x)) + raise support.TestFailed("Unexpected SSL error: " + str(x)) except Exception as x: - raise test_support.TestFailed("Unexpected exception: " + str(x)) + raise support.TestFailed("Unexpected exception: " + str(x)) else: - if test_support.verbose: + if support.verbose: sys.stdout.write( " client: sending %s...\n" % (repr(indata))) s.sendall(indata.encode('ASCII', 'strict')) outdata = s.recv() - if test_support.verbose: + if support.verbose: sys.stdout.write(" client: read %s\n" % repr(outdata)) outdata = str(outdata, 'ASCII', 'strict') if outdata != indata.lower(): - raise test_support.TestFailed( + raise support.TestFailed( "bad data <<%s>> (%d) received; expected <<%s>> (%d)\n" % (repr(outdata[:min(len(outdata),20)]), len(outdata), repr(indata[:min(len(indata),20)].lower()), len(indata))) s.write("over\n".encode("ASCII", "strict")) - if test_support.verbose: + if support.verbose: sys.stdout.write(" client: closing connection.\n") s.close() finally: @@ -1015,7 +1015,7 @@ else: def test_main(verbose=False): if skip_expected: - raise test_support.TestSkipped("No SSL support") + raise support.TestSkipped("No SSL support") global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, @@ -1026,22 +1026,22 @@ def test_main(verbose=False): if (not os.path.exists(CERTFILE) or not os.path.exists(SVN_PYTHON_ORG_ROOT_CERT)): - raise test_support.TestFailed("Can't read certificate files!") + raise support.TestFailed("Can't read certificate files!") tests = [BasicTests] - if test_support.is_resource_enabled('network'): + if support.is_resource_enabled('network'): tests.append(NetworkedTests) if _have_threads: - thread_info = test_support.threading_setup() - if thread_info and test_support.is_resource_enabled('network'): + thread_info = support.threading_setup() + if thread_info and support.is_resource_enabled('network'): tests.append(ThreadedTests) - test_support.run_unittest(*tests) + support.run_unittest(*tests) if _have_threads: - test_support.threading_cleanup(*thread_info) + support.threading_cleanup(*thread_info) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_startfile.py b/Lib/test/test_startfile.py index db09946..8d23dbb 100644 --- a/Lib/test/test_startfile.py +++ b/Lib/test/test_startfile.py @@ -8,7 +8,7 @@ # call succeeded, but also the the script actually has run. import unittest -from test import test_support +from test import support # use this form so that the test is skipped when startfile is not available: from os import startfile, path @@ -23,7 +23,7 @@ class TestCase(unittest.TestCase): startfile(empty, "open") def test_main(): - test_support.run_unittest(TestCase) + support.run_unittest(TestCase) if __name__=="__main__": test_main() diff --git a/Lib/test/test_strftime.py b/Lib/test/test_strftime.py index 5af5a0c..7128fd7 100755 --- a/Lib/test/test_strftime.py +++ b/Lib/test/test_strftime.py @@ -6,7 +6,7 @@ import calendar import sys import os import re -from test import test_support +from test import support import time import unittest @@ -68,7 +68,7 @@ class StrftimeTest(unittest.TestCase): self.strftest1(now) self.strftest2(now) - if test_support.verbose: + if support.verbose: print("Strftime test, platform: %s, Python version: %s" % \ (sys.platform, sys.version.split()[0])) @@ -80,7 +80,7 @@ class StrftimeTest(unittest.TestCase): self.strftest2(arg) def strftest1(self, now): - if test_support.verbose: + if support.verbose: print("strftime test for", time.ctime(now)) now = self.now # Make sure any characters that could be taken as regex syntax is @@ -162,24 +162,24 @@ class StrftimeTest(unittest.TestCase): except ValueError as result: msg = "Error for nonstandard '%s' format (%s): %s" % \ (e[0], e[2], str(result)) - if test_support.verbose: + if support.verbose: print(msg) continue if re.match(escapestr(e[1], self.ampm), result): - if test_support.verbose: + if support.verbose: print("Supports nonstandard '%s' format (%s)" % (e[0], e[2])) elif not result or result[0] == '%': - if test_support.verbose: + if support.verbose: print("Does not appear to support '%s' format (%s)" % \ (e[0], e[2])) else: - if test_support.verbose: + if support.verbose: print("Conflict for nonstandard '%s' format (%s):" % \ (e[0], e[2])) print(" Expected %s, but got %s" % (e[1], result)) def test_main(): - test_support.run_unittest(StrftimeTest) + support.run_unittest(StrftimeTest) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_string.py b/Lib/test/test_string.py index 4c3c964..66f2204 100644 --- a/Lib/test/test_string.py +++ b/Lib/test/test_string.py @@ -1,5 +1,5 @@ import unittest, string -from test import test_support +from test import support class ModuleTest(unittest.TestCase): @@ -110,7 +110,7 @@ class ModuleTest(unittest.TestCase): self.assertRaises(TypeError, string.maketrans, 'abc', 'def') def test_main(): - test_support.run_unittest(ModuleTest) + support.run_unittest(ModuleTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_stringprep.py b/Lib/test/test_stringprep.py index 0452790..f3d3327 100644 --- a/Lib/test/test_stringprep.py +++ b/Lib/test/test_stringprep.py @@ -2,7 +2,7 @@ # Since we don't have them, this test checks only a few codepoints. import unittest -from test import test_support +from test import support from stringprep import * @@ -90,7 +90,7 @@ class StringprepTests(unittest.TestCase): # print p, h.hexdigest() def test_main(): - test_support.run_unittest(StringprepTests) + support.run_unittest(StringprepTests) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py index ac8905a..436a487 100644 --- a/Lib/test/test_strptime.py +++ b/Lib/test/test_strptime.py @@ -5,7 +5,7 @@ import time import locale import re import sys -from test import test_support +from test import support from datetime import date as datetime_date import _strptime @@ -551,7 +551,7 @@ class CacheTests(unittest.TestCase): def test_main(): - test_support.run_unittest( + support.run_unittest( getlang_Tests, LocaleTime_Tests, TimeRETests, diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py index 61b5f6c..05ac760 100644 --- a/Lib/test/test_struct.py +++ b/Lib/test/test_struct.py @@ -1,5 +1,5 @@ -from test.test_support import TestFailed, verbose, verify, vereq -import test.test_support +from test.support import TestFailed, verbose, verify, vereq +import test.support import struct import array import warnings @@ -50,7 +50,7 @@ def any_err(func, *args): def with_warning_restore(func): def _with_warning_restore(*args, **kw): - with test.test_support.catch_warning(): + with test.support.catch_warning(): # Grrr, we need this function to warn every time. Without removing # the warningregistry, running test_tarfile then test_struct would fail # on 64-bit platforms. diff --git a/Lib/test/test_structmembers.py b/Lib/test/test_structmembers.py index 97d7b23..d6c9fea 100644 --- a/Lib/test/test_structmembers.py +++ b/Lib/test/test_structmembers.py @@ -6,7 +6,7 @@ from _testcapi import test_structmembersType, \ LLONG_MAX, LLONG_MIN, ULLONG_MAX import warnings, unittest, sys -from test import test_support +from test import support ts=test_structmembersType(False, 1, 2, 3, 4, 5, 6, 7, 8, 9.99999, 10.1010101010) @@ -69,39 +69,39 @@ class TestWarnings(unittest.TestCase): self.assertEqual(w.category, RuntimeWarning) def test_byte_max(self): - with test_support.catch_warning() as w: + with support.catch_warning() as w: ts.T_BYTE = CHAR_MAX+1 self.has_warned(w) def test_byte_min(self): - with test_support.catch_warning() as w: + with support.catch_warning() as w: ts.T_BYTE = CHAR_MIN-1 self.has_warned(w) def test_ubyte_max(self): - with test_support.catch_warning() as w: + with support.catch_warning() as w: ts.T_UBYTE = UCHAR_MAX+1 self.has_warned(w) def test_short_max(self): - with test_support.catch_warning() as w: + with support.catch_warning() as w: ts.T_SHORT = SHRT_MAX+1 self.has_warned(w) def test_short_min(self): - with test_support.catch_warning() as w: + with support.catch_warning() as w: ts.T_SHORT = SHRT_MIN-1 self.has_warned(w) def test_ushort_max(self): - with test_support.catch_warning() as w: + with support.catch_warning() as w: ts.T_USHORT = USHRT_MAX+1 self.has_warned(w) def test_main(verbose=None): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": test_main(verbose=True) diff --git a/Lib/test/test_structseq.py b/Lib/test/test_structseq.py index 7ba142b..124acff 100644 --- a/Lib/test/test_structseq.py +++ b/Lib/test/test_structseq.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support import time @@ -114,7 +114,7 @@ class StructSeqTest(unittest.TestCase): L[start:stop:step]) def test_main(): - test_support.run_unittest(StructSeqTest) + support.run_unittest(StructSeqTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index 3d6777f..5a325ce 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support import subprocess import sys import signal @@ -31,14 +31,14 @@ class ProcessTestCase(unittest.TestCase): def setUp(self): # Try to minimize the number of children we have so this test # doesn't crash on some buildbots (Alphas in particular). - if hasattr(test_support, "reap_children"): - test_support.reap_children() + if hasattr(support, "reap_children"): + support.reap_children() def tearDown(self): # Try to minimize the number of children we have so this test # doesn't crash on some buildbots (Alphas in particular). - if hasattr(test_support, "reap_children"): - test_support.reap_children() + if hasattr(support, "reap_children"): + support.reap_children() def mkstemp(self): """wrapper for mkstemp, calling mktemp if mkstemp is not available""" @@ -392,8 +392,8 @@ class ProcessTestCase(unittest.TestCase): def test_no_leaking(self): # Make sure we leak no resources - if (not hasattr(test_support, "is_resource_enabled") or - test_support.is_resource_enabled("subprocess") and not mswindows): + if (not hasattr(support, "is_resource_enabled") or + support.is_resource_enabled("subprocess") and not mswindows): max_handles = 1026 # too much for most UNIX systems else: max_handles = 65 @@ -703,9 +703,9 @@ class ProcessTestCase(unittest.TestCase): self.assertNotEqual(p.wait(), 0) def test_main(): - test_support.run_unittest(ProcessTestCase) - if hasattr(test_support, "reap_children"): - test_support.reap_children() + support.run_unittest(ProcessTestCase) + if hasattr(support, "reap_children"): + support.reap_children() if __name__ == "__main__": unittest.main() # XXX test_main() diff --git a/Lib/test/test_sundry.py b/Lib/test/test_sundry.py index 1b6069d..292722d 100644 --- a/Lib/test/test_sundry.py +++ b/Lib/test/test_sundry.py @@ -1,13 +1,13 @@ """Do a minimal test of all the modules that aren't otherwise tested.""" -from test import test_support +from test import support import sys import unittest import warnings class TestUntestedModules(unittest.TestCase): def test_at_least_import_untested_modules(self): - with test_support.catch_warning(): + with support.catch_warning(): import CGIHTTPServer import aifc import bdb @@ -73,14 +73,14 @@ class TestUntestedModules(unittest.TestCase): try: import tty # not available on Windows except ImportError: - if test_support.verbose: + if support.verbose: print("skipping tty") import webbrowser import xml def test_main(): - test_support.run_unittest(TestUntestedModules) + support.run_unittest(TestUntestedModules) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_super.py b/Lib/test/test_super.py index fc303ea..5594b11 100644 --- a/Lib/test/test_super.py +++ b/Lib/test/test_super.py @@ -2,7 +2,7 @@ import sys import unittest -from test import test_support +from test import support class A: @@ -72,7 +72,7 @@ class TestSuper(unittest.TestCase): def test_main(): - test_support.run_unittest(TestSuper) + support.run_unittest(TestSuper) if __name__ == "__main__": diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py deleted file mode 100644 index c4084bb..0000000 --- a/Lib/test/test_support.py +++ /dev/null @@ -1,769 +0,0 @@ -"""Supporting definitions for the Python regression tests.""" - -if __name__ != 'test.test_support': - raise ImportError('test_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 - test_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_symtable.py b/Lib/test/test_symtable.py index 74a7c85..77115e0 100644 --- a/Lib/test/test_symtable.py +++ b/Lib/test/test_symtable.py @@ -1,4 +1,4 @@ -from test import test_support +from test import support import symtable import unittest @@ -38,7 +38,7 @@ class SymtableTest(unittest.TestCase): def test_main(): - test_support.run_unittest(SymtableTest) + support.run_unittest(SymtableTest) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index 546f7a8..11ca4ea 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -476,7 +476,7 @@ import re import unittest import warnings -from test import test_support +from test import support class SyntaxTestCase(unittest.TestCase): @@ -548,9 +548,9 @@ class SyntaxTestCase(unittest.TestCase): self._check_error("int(base=10, '2')", "non-keyword arg") def test_main(): - test_support.run_unittest(SyntaxTestCase) + support.run_unittest(SyntaxTestCase) from test import test_syntax - test_support.run_doctest(test_syntax, verbosity=True) + support.run_doctest(test_syntax, verbosity=True) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index 3a0abe1..7c66e0d 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -import unittest, test.test_support +import unittest, test.support import sys, io class SysModuleTest(unittest.TestCase): @@ -350,7 +350,7 @@ class SysModuleTest(unittest.TestCase): #self.assert_(r[0][2] > 100, r[0][2]) def test_main(): - test.test_support.run_unittest(SysModuleTest) + test.support.run_unittest(SysModuleTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_syslog.py b/Lib/test/test_syslog.py index 3f22c0d..3a3d635 100644 --- a/Lib/test/test_syslog.py +++ b/Lib/test/test_syslog.py @@ -1,7 +1,7 @@ import syslog import unittest -from test import test_support +from test import support # XXX(nnorwitz): This test sucks. I don't know of a platform independent way # to verify that the messages were really logged. @@ -31,7 +31,7 @@ class Test(unittest.TestCase): syslog.LOG_UPTO(syslog.LOG_INFO) def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py index 2fbb51e..9fde707 100644 --- a/Lib/test/test_tarfile.py +++ b/Lib/test/test_tarfile.py @@ -10,7 +10,7 @@ import errno import unittest import tarfile -from test import test_support +from test import support # Check for our compression modules. try: @@ -27,7 +27,7 @@ def md5sum(data): return md5(data).hexdigest() def path(path): - return test_support.findfile(path) + return support.findfile(path) TEMPDIR = os.path.join(tempfile.gettempdir(), "test_tarfile_tmp") tarname = path("testtar.tar") @@ -1171,7 +1171,7 @@ def test_main(): ] try: - test_support.run_unittest(*tests) + support.run_unittest(*tests) finally: if os.path.exists(TEMPDIR): shutil.rmtree(TEMPDIR) diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py index 4255d8a..9a327dc 100644 --- a/Lib/test/test_tcl.py +++ b/Lib/test/test_tcl.py @@ -2,7 +2,7 @@ import unittest import os -from test import test_support +from test import support from Tkinter import Tcl from _tkinter import TclError @@ -151,7 +151,7 @@ class TclTest(unittest.TestCase): os.environ['DISPLAY'] = old_display def test_main(): - test_support.run_unittest(TclTest) + support.run_unittest(TclTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_telnetlib.py b/Lib/test/test_telnetlib.py index e4ee1b5..c24d41d 100644 --- a/Lib/test/test_telnetlib.py +++ b/Lib/test/test_telnetlib.py @@ -4,9 +4,9 @@ import telnetlib import time from unittest import TestCase -from test import test_support +from test import support -HOST = test_support.HOST +HOST = support.HOST def server(evt, serv): serv.listen(5) @@ -25,7 +25,7 @@ class GeneralTests(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) threading.Thread(target=server, args=(self.evt,self.sock)).start() self.evt.wait() self.evt.clear() @@ -71,7 +71,7 @@ class GeneralTests(TestCase): def test_main(verbose=None): - test_support.run_unittest(GeneralTests) + support.run_unittest(GeneralTests) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py index e88efeb..5a81455 100644 --- a/Lib/test/test_tempfile.py +++ b/Lib/test/test_tempfile.py @@ -7,7 +7,7 @@ import errno import warnings import unittest -from test import test_support +from test import support warnings.filterwarnings("ignore", category=RuntimeWarning, @@ -116,7 +116,7 @@ class test__RandomNameSequence(TC): self.failIf(s in dict) dict[s] = 1 - def test_supports_iter(self): + def supports_iter(self): # _RandomNameSequence supports the iterator protocol i = 0 @@ -276,7 +276,7 @@ class test__mkstemp_inner(TC): if not has_spawnl: return # ugh, can't use TestSkipped. - if test_support.verbose: + if support.verbose: v="v" else: v="q" @@ -881,7 +881,7 @@ if tempfile.NamedTemporaryFile is not tempfile.TemporaryFile: test_classes.append(test_TemporaryFile) def test_main(): - test_support.run_unittest(*test_classes) + support.run_unittest(*test_classes) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_textwrap.py b/Lib/test/test_textwrap.py index 1a9761a..1cbd9ce 100644 --- a/Lib/test/test_textwrap.py +++ b/Lib/test/test_textwrap.py @@ -9,7 +9,7 @@ # import unittest -from test import test_support +from test import support from textwrap import TextWrapper, wrap, fill, dedent @@ -579,7 +579,7 @@ def foo(): def test_main(): - test_support.run_unittest(WrapTestCase, + support.run_unittest(WrapTestCase, LongWordTestCase, IndentTestCases, DedentTestCase) diff --git a/Lib/test/test_thread.py b/Lib/test/test_thread.py index 01d6655..cff9f81 100644 --- a/Lib/test/test_thread.py +++ b/Lib/test/test_thread.py @@ -1,7 +1,7 @@ import os import unittest import random -from test import test_support +from test import support import thread import time @@ -13,7 +13,7 @@ _print_mutex = thread.allocate_lock() def verbose_print(arg): """Helper function for printing out debugging output.""" - if test_support.verbose: + if support.verbose: with _print_mutex: print(arg) @@ -159,7 +159,7 @@ class BarrierTest(BasicThreadTest): self.done_mutex.release() def test_main(): - test_support.run_unittest(ThreadRunningTests, BarrierTest) + support.run_unittest(ThreadRunningTests, BarrierTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_threaded_import.py b/Lib/test/test_threaded_import.py index 41a2b90..fbe479c 100644 --- a/Lib/test/test_threaded_import.py +++ b/Lib/test/test_threaded_import.py @@ -6,7 +6,7 @@ # randrange, and then Python hangs. import thread -from test.test_support import verbose, TestSkipped, TestFailed +from test.support import verbose, TestSkipped, TestFailed critical_section = thread.allocate_lock() done = thread.allocate_lock() diff --git a/Lib/test/test_threadedtempfile.py b/Lib/test/test_threadedtempfile.py index cde15b4..fb122d0 100644 --- a/Lib/test/test_threadedtempfile.py +++ b/Lib/test/test_threadedtempfile.py @@ -20,7 +20,7 @@ import thread # If this fails, we can't test this module import threading import tempfile -from test.test_support import threading_setup, threading_cleanup, run_unittest +from test.support import threading_setup, threading_cleanup, run_unittest import unittest import io from traceback import print_exc diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py index 1017f56..9582dde 100644 --- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@ -1,7 +1,7 @@ # Very rudimentary test of threading module -import test.test_support -from test.test_support import verbose +import test.support +from test.support import verbose import random import sys import threading @@ -356,7 +356,7 @@ class ThreadingExceptionTests(unittest.TestCase): def test_main(): - test.test_support.run_unittest(ThreadTests, + test.support.run_unittest(ThreadTests, ThreadingExceptionTests) if __name__ == "__main__": diff --git a/Lib/test/test_threading_local.py b/Lib/test/test_threading_local.py index b7dd538..e48dc59 100644 --- a/Lib/test/test_threading_local.py +++ b/Lib/test/test_threading_local.py @@ -1,6 +1,6 @@ import unittest from doctest import DocTestSuite -from test import test_support +from test import support import threading import weakref import gc @@ -62,7 +62,7 @@ def test_main(): setUp=setUp, tearDown=tearDown) ) - test_support.run_unittest(suite) + support.run_unittest(suite) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_threadsignals.py b/Lib/test/test_threadsignals.py index 2f014e1..cbed42c 100644 --- a/Lib/test/test_threadsignals.py +++ b/Lib/test/test_threadsignals.py @@ -5,7 +5,7 @@ import thread import signal import os import sys -from test.test_support import run_unittest, TestSkipped +from test.support import run_unittest, TestSkipped if sys.platform[:3] in ('win', 'os2'): raise TestSkipped("Can't test signal on %s" % sys.platform) diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py index 3a7fa0f..4c89f03 100644 --- a/Lib/test/test_time.py +++ b/Lib/test/test_time.py @@ -1,4 +1,4 @@ -from test import test_support +from test import support import time import unittest @@ -219,7 +219,7 @@ class TimeTestCase(unittest.TestCase): self.assert_(0 <= (t1-t0) < 0.2) def test_main(): - test_support.run_unittest(TimeTestCase) + support.run_unittest(TimeTestCase) if __name__ == "__main__": diff --git a/Lib/test/test_timeout.py b/Lib/test/test_timeout.py index 6324fc1..264704e 100644 --- a/Lib/test/test_timeout.py +++ b/Lib/test/test_timeout.py @@ -1,10 +1,10 @@ """Unit tests for socket timeout feature.""" import unittest -from test import test_support +from test import support # This requires the 'network' resource as given on the regrtest command line. -skip_expected = not test_support.is_resource_enabled('network') +skip_expected = not support.is_resource_enabled('network') import time import socket @@ -191,8 +191,8 @@ class TimeoutTestCase(unittest.TestCase): def test_main(): - test_support.requires('network') - test_support.run_unittest(CreationTestCase, TimeoutTestCase) + support.requires('network') + support.run_unittest(CreationTestCase, TimeoutTestCase) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_tokenize.py b/Lib/test/test_tokenize.py index ea9030b..8fbd216 100644 --- a/Lib/test/test_tokenize.py +++ b/Lib/test/test_tokenize.py @@ -60,7 +60,7 @@ two trailing blanks apparent in the expected output. ... " print(x)\\n") True - >>> f = test_support.findfile("tokenize_tests.txt") + >>> f = support.findfile("tokenize_tests.txt") >>> roundtrip(open(f, 'rb')) True @@ -522,7 +522,7 @@ pass the '-ucompiler' option to process the full directory. >>> tempdir = os.path.dirname(f) or os.curdir >>> testfiles = glob.glob(os.path.join(tempdir, "test*.py")) - >>> if not test_support.is_resource_enabled("compiler"): + >>> if not support.is_resource_enabled("compiler"): ... testfiles = random.sample(testfiles, 10) ... >>> for testfile in testfiles: @@ -533,7 +533,7 @@ pass the '-ucompiler' option to process the full directory. True """ -from test import test_support +from test import support from tokenize import (tokenize, _tokenize, untokenize, NUMBER, NAME, OP, STRING, ENDMARKER, tok_name, detect_encoding) from io import BytesIO @@ -842,11 +842,11 @@ __test__ = {"doctests" : doctests, 'decistmt': decistmt} def test_main(): from test import test_tokenize - test_support.run_doctest(test_tokenize, True) - test_support.run_unittest(TestTokenizerAdheresToPep0263) - test_support.run_unittest(Test_Tokenize) - test_support.run_unittest(TestDetectEncoding) - test_support.run_unittest(TestTokenize) + support.run_doctest(test_tokenize, True) + support.run_unittest(TestTokenizerAdheresToPep0263) + support.run_unittest(Test_Tokenize) + support.run_unittest(TestDetectEncoding) + support.run_unittest(TestTokenize) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_trace.py b/Lib/test/test_trace.py index 9ecd995..48a717b 100644 --- a/Lib/test/test_trace.py +++ b/Lib/test/test_trace.py @@ -1,6 +1,6 @@ # Testing the line trace facility. -from test import test_support +from test import support import unittest import sys import difflib @@ -742,7 +742,7 @@ class JumpTestCase(unittest.TestCase): no_jump_without_trace_function() def test_main(): - test_support.run_unittest( + support.run_unittest( TraceTestCase, RaisingTraceFuncTestCase, JumpTestCase diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py index 600c7b5..3f89e6a 100644 --- a/Lib/test/test_traceback.py +++ b/Lib/test/test_traceback.py @@ -4,7 +4,7 @@ from _testcapi import traceback_print from io import StringIO import sys import unittest -from test.test_support import run_unittest, is_jython, Error +from test.support import run_unittest, is_jython, Error import traceback diff --git a/Lib/test/test_tuple.py b/Lib/test/test_tuple.py index 77672e7..de08131 100644 --- a/Lib/test/test_tuple.py +++ b/Lib/test/test_tuple.py @@ -1,4 +1,4 @@ -from test import test_support, seq_tests +from test import support, seq_tests class TupleTest(seq_tests.CommonTest): type2test = tuple @@ -83,7 +83,7 @@ class TupleTest(seq_tests.CommonTest): self.assertEqual(repr(a2), "(0, 1, 2)") def test_main(): - test_support.run_unittest(TupleTest) + support.run_unittest(TupleTest) if __name__=="__main__": test_main() diff --git a/Lib/test/test_typechecks.py b/Lib/test/test_typechecks.py index 1dcc82c..901c326 100644 --- a/Lib/test/test_typechecks.py +++ b/Lib/test/test_typechecks.py @@ -1,7 +1,7 @@ """Unit tests for __instancecheck__ and __subclasscheck__.""" import unittest -from test import test_support +from test import support class ABC(type): @@ -56,7 +56,7 @@ class TypeChecksTest(unittest.TestCase): def test_main(): - test_support.run_unittest(TypeChecksTest) + support.run_unittest(TypeChecksTest) if __name__ == "__main__": diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py index 2fc0004..948e8d4 100644 --- a/Lib/test/test_types.py +++ b/Lib/test/test_types.py @@ -1,6 +1,6 @@ # Python test set -- part 6, built-in types -from test.test_support import run_unittest, run_with_locale +from test.support import run_unittest, run_with_locale import unittest import sys import locale diff --git a/Lib/test/test_ucn.py b/Lib/test/test_ucn.py index 78cb780..2d48179 100644 --- a/Lib/test/test_ucn.py +++ b/Lib/test/test_ucn.py @@ -9,7 +9,7 @@ Modified for Python 2.0 by Fredrik Lundh (fredrik@pythonware.com) import unittest -from test import test_support +from test import support class UnicodeNamesTest(unittest.TestCase): @@ -138,7 +138,7 @@ class UnicodeNamesTest(unittest.TestCase): ) def test_main(): - test_support.run_unittest(UnicodeNamesTest) + support.run_unittest(UnicodeNamesTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_unary.py b/Lib/test/test_unary.py index dbefe62..7dd651e 100644 --- a/Lib/test/test_unary.py +++ b/Lib/test/test_unary.py @@ -1,7 +1,7 @@ """Test compiler changes for unary ops (+, -, ~) introduced in Python 2.2""" import unittest -from test.test_support import run_unittest +from test.support import run_unittest class UnaryOpTestCase(unittest.TestCase): diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py index c64dee5..2f9add5 100644 --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -11,7 +11,7 @@ import struct import sys import unittest import warnings -from test import test_support, string_tests +from test import support, string_tests # Error handling (bad decoder return) def search_function(encoding): @@ -671,7 +671,7 @@ class UnicodeTest( return '\u1234' self.assertEqual('%s' % Wrapper(), '\u1234') - @test_support.run_with_locale('LC_ALL', 'de_DE', 'fr_FR') + @support.run_with_locale('LC_ALL', 'de_DE', 'fr_FR') def test_format_float(self): # should not format with a comma, but always with C locale self.assertEqual('1.0', '%.1f' % 1.0) @@ -1077,7 +1077,7 @@ class UnicodeTest( def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_unicode_file.py b/Lib/test/test_unicode_file.py index 5f0681e..cc670db 100644 --- a/Lib/test/test_unicode_file.py +++ b/Lib/test/test_unicode_file.py @@ -5,8 +5,8 @@ import os, glob, time, shutil import unicodedata import unittest -from test.test_support import run_unittest, TestSkipped, TESTFN_UNICODE -from test.test_support import TESTFN_ENCODING, TESTFN_UNICODE_UNENCODEABLE +from test.support import run_unittest, TestSkipped, TESTFN_UNICODE +from test.support import TESTFN_ENCODING, TESTFN_UNICODE_UNENCODEABLE try: TESTFN_UNICODE.encode(TESTFN_ENCODING) except (UnicodeError, TypeError): diff --git a/Lib/test/test_unicodedata.py b/Lib/test/test_unicodedata.py index c4ea816..08208f9 100644 --- a/Lib/test/test_unicodedata.py +++ b/Lib/test/test_unicodedata.py @@ -5,7 +5,7 @@ (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. """#" -import unittest, test.test_support +import unittest, test.support import hashlib encoding = 'utf-8' @@ -219,7 +219,7 @@ class UnicodeMiscTest(UnicodeDatabaseTest): self.assertEquals(self.db.lookup("GOTHIC LETTER FAIHU"), '\U00010346') def test_main(): - test.test_support.run_unittest( + test.support.run_unittest( UnicodeMiscTest, UnicodeMethodsTest, UnicodeFunctionsTest diff --git a/Lib/test/test_unittest.py b/Lib/test/test_unittest.py index ed27618..c9c17d3 100644 --- a/Lib/test/test_unittest.py +++ b/Lib/test/test_unittest.py @@ -6,7 +6,7 @@ Still need testing: TestCase.{assert,fail}* methods (some are tested implicitly) """ -from test import test_support +from test import support import unittest from unittest import TestCase import types @@ -2289,7 +2289,7 @@ class Test_Assertions(TestCase): ###################################################################### def test_main(): - test_support.run_unittest(Test_TestCase, Test_TestLoader, + support.run_unittest(Test_TestCase, Test_TestLoader, Test_TestSuite, Test_TestResult, Test_FunctionTestCase, Test_Assertions) diff --git a/Lib/test/test_univnewlines.py b/Lib/test/test_univnewlines.py index c3b7bc4..c4e4a3f 100644 --- a/Lib/test/test_univnewlines.py +++ b/Lib/test/test_univnewlines.py @@ -2,10 +2,10 @@ import unittest import os import sys -from test import test_support +from test import support if not hasattr(sys.stdin, 'newlines'): - raise test_support.TestSkipped( + raise support.TestSkipped( "This Python does not have universal newline support") FATX = 'x' * (2**14) @@ -35,7 +35,7 @@ class TestGenericUnivNewlines(unittest.TestCase): WRITEMODE = 'wb' def setUp(self): - fp = open(test_support.TESTFN, self.WRITEMODE) + fp = open(support.TESTFN, self.WRITEMODE) data = self.DATA if "b" in self.WRITEMODE: data = data.encode("ascii") @@ -44,24 +44,24 @@ class TestGenericUnivNewlines(unittest.TestCase): def tearDown(self): try: - os.unlink(test_support.TESTFN) + os.unlink(support.TESTFN) except: pass def test_read(self): - fp = open(test_support.TESTFN, self.READMODE) + fp = open(support.TESTFN, self.READMODE) data = fp.read() self.assertEqual(data, DATA_LF) self.assertEqual(repr(fp.newlines), repr(self.NEWLINE)) def test_readlines(self): - fp = open(test_support.TESTFN, self.READMODE) + fp = open(support.TESTFN, self.READMODE) data = fp.readlines() self.assertEqual(data, DATA_SPLIT) self.assertEqual(repr(fp.newlines), repr(self.NEWLINE)) def test_readline(self): - fp = open(test_support.TESTFN, self.READMODE) + fp = open(support.TESTFN, self.READMODE) data = [] d = fp.readline() while d: @@ -71,7 +71,7 @@ class TestGenericUnivNewlines(unittest.TestCase): self.assertEqual(repr(fp.newlines), repr(self.NEWLINE)) def test_seek(self): - fp = open(test_support.TESTFN, self.READMODE) + fp = open(support.TESTFN, self.READMODE) fp.readline() pos = fp.tell() data = fp.readlines() @@ -94,7 +94,7 @@ class TestCRLFNewlines(TestGenericUnivNewlines): DATA = DATA_CRLF def test_tell(self): - fp = open(test_support.TESTFN, self.READMODE) + fp = open(support.TESTFN, self.READMODE) self.assertEqual(repr(fp.newlines), repr(None)) data = fp.readline() pos = fp.tell() @@ -106,7 +106,7 @@ class TestMixedNewlines(TestGenericUnivNewlines): def test_main(): - test_support.run_unittest( + support.run_unittest( TestCRNewlines, TestLFNewlines, TestCRLFNewlines, diff --git a/Lib/test/test_unpack.py b/Lib/test/test_unpack.py index a90b5e5..b1531f3 100644 --- a/Lib/test/test_unpack.py +++ b/Lib/test/test_unpack.py @@ -122,9 +122,9 @@ error) __test__ = {'doctests' : doctests} def test_main(verbose=False): - from test import test_support + from test import support from test import test_unpack - test_support.run_doctest(test_unpack, verbose) + support.run_doctest(test_unpack, verbose) if __name__ == "__main__": test_main(verbose=True) diff --git a/Lib/test/test_unpack_ex.py b/Lib/test/test_unpack_ex.py index 89486b8..ae2dcbd 100644 --- a/Lib/test/test_unpack_ex.py +++ b/Lib/test/test_unpack_ex.py @@ -166,9 +166,9 @@ __test__ = {'doctests' : doctests} def test_main(verbose=False): import sys - from test import test_support + from test import support from test import test_unpack_ex - test_support.run_doctest(test_unpack_ex, verbose) + support.run_doctest(test_unpack_ex, verbose) if __name__ == "__main__": test_main(verbose=True) diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py index d58414c..7db281c 100644 --- a/Lib/test/test_urllib.py +++ b/Lib/test/test_urllib.py @@ -4,7 +4,7 @@ import urllib import httplib import io import unittest -from test import test_support +from test import support import os import mimetools import tempfile @@ -27,18 +27,18 @@ class urlopen_FileTests(unittest.TestCase): def setUp(self): """Setup of a temp file to use for testing""" self.text = bytes("test_urllib: %s\n" % self.__class__.__name__, "ascii") - FILE = open(test_support.TESTFN, 'wb') + FILE = open(support.TESTFN, 'wb') try: FILE.write(self.text) finally: FILE.close() - self.pathname = test_support.TESTFN + self.pathname = support.TESTFN self.returned_obj = urllib.urlopen("file:%s" % self.pathname) def tearDown(self): """Shut down the open object""" self.returned_obj.close() - os.remove(test_support.TESTFN) + os.remove(support.TESTFN) def test_interface(self): # Make sure object returned by urlopen() has the specified methods @@ -163,10 +163,10 @@ class urlretrieve_FileTests(unittest.TestCase): self.tempFiles = [] # Create a temporary file. - self.registerFileForCleanUp(test_support.TESTFN) + self.registerFileForCleanUp(support.TESTFN) self.text = b'testing urllib.urlretrieve' try: - FILE = open(test_support.TESTFN, 'wb') + FILE = open(support.TESTFN, 'wb') FILE.write(self.text) FILE.close() finally: @@ -204,18 +204,18 @@ class urlretrieve_FileTests(unittest.TestCase): def test_basic(self): # Make sure that a local file just gets its own location returned and # a headers value is returned. - result = urllib.urlretrieve("file:%s" % test_support.TESTFN) - self.assertEqual(result[0], test_support.TESTFN) + result = urllib.urlretrieve("file:%s" % support.TESTFN) + self.assertEqual(result[0], support.TESTFN) self.assert_(isinstance(result[1], mimetools.Message), "did not get a mimetools.Message instance as second " "returned value") def test_copy(self): # Test that setting the filename argument works. - second_temp = "%s.2" % test_support.TESTFN + second_temp = "%s.2" % support.TESTFN self.registerFileForCleanUp(second_temp) result = urllib.urlretrieve(self.constructLocalFileUrl( - test_support.TESTFN), second_temp) + support.TESTFN), second_temp) self.assertEqual(second_temp, result[0]) self.assert_(os.path.exists(second_temp), "copy of the file was not " "made") @@ -236,9 +236,9 @@ class urlretrieve_FileTests(unittest.TestCase): self.assert_(isinstance(total_size, int)) self.assertEqual(count, count_holder[0]) count_holder[0] = count_holder[0] + 1 - second_temp = "%s.2" % test_support.TESTFN + second_temp = "%s.2" % support.TESTFN self.registerFileForCleanUp(second_temp) - urllib.urlretrieve(self.constructLocalFileUrl(test_support.TESTFN), + urllib.urlretrieve(self.constructLocalFileUrl(support.TESTFN), second_temp, hooktester) def test_reporthook_0_bytes(self): @@ -248,7 +248,7 @@ class urlretrieve_FileTests(unittest.TestCase): _report.append((count, block_size, total_size)) srcFileName = self.createNewTempFile() urllib.urlretrieve(self.constructLocalFileUrl(srcFileName), - test_support.TESTFN, hooktester) + support.TESTFN, hooktester) self.assertEqual(len(report), 1) self.assertEqual(report[0][2], 0) @@ -262,7 +262,7 @@ class urlretrieve_FileTests(unittest.TestCase): _report.append((count, block_size, total_size)) srcFileName = self.createNewTempFile(b"x" * 5) urllib.urlretrieve(self.constructLocalFileUrl(srcFileName), - test_support.TESTFN, hooktester) + support.TESTFN, hooktester) self.assertEqual(len(report), 2) self.assertEqual(report[0][1], 8192) self.assertEqual(report[0][2], 5) @@ -276,7 +276,7 @@ class urlretrieve_FileTests(unittest.TestCase): _report.append((count, block_size, total_size)) srcFileName = self.createNewTempFile(b"x" * 8193) urllib.urlretrieve(self.constructLocalFileUrl(srcFileName), - test_support.TESTFN, hooktester) + support.TESTFN, hooktester) self.assertEqual(len(report), 3) self.assertEqual(report[0][1], 8192) self.assertEqual(report[0][2], 8193) @@ -632,7 +632,7 @@ class Pathname_Tests(unittest.TestCase): def test_main(): - test_support.run_unittest( + support.run_unittest( urlopen_FileTests, urlopen_HttpTests, urlretrieve_FileTests, diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py index d34a177..cb730e2 100644 --- a/Lib/test/test_urllib2.py +++ b/Lib/test/test_urllib2.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support import os import io @@ -588,7 +588,7 @@ class HandlerTests(unittest.TestCase): h = urllib2.FileHandler() o = h.parent = MockOpener() - TESTFN = test_support.TESTFN + TESTFN = support.TESTFN urlpath = sanepathname2url(os.path.abspath(TESTFN)) towrite = b"hello, world\n" urls = [ @@ -1075,13 +1075,13 @@ class MiscTests(unittest.TestCase): def test_main(verbose=None): from test import test_urllib2 - test_support.run_doctest(test_urllib2, verbose) - test_support.run_doctest(urllib2, verbose) + support.run_doctest(test_urllib2, verbose) + support.run_doctest(urllib2, verbose) tests = (TrivialTests, OpenerDirectorTests, HandlerTests, MiscTests) - test_support.run_unittest(*tests) + support.run_unittest(*tests) if __name__ == "__main__": test_main(verbose=True) diff --git a/Lib/test/test_urllib2_localnet.py b/Lib/test/test_urllib2_localnet.py index 0815658..6bf1820 100644 --- a/Lib/test/test_urllib2_localnet.py +++ b/Lib/test/test_urllib2_localnet.py @@ -7,7 +7,7 @@ import urllib2 import BaseHTTPServer import unittest import hashlib -from test import test_support +from test import support # Loopback http server infrastructure @@ -481,10 +481,10 @@ def test_main(): # (Lib/test/regrtest.py -u network) since all tests here are only # localhost. However, if this is a bad rationale, then uncomment # the next line. - #test_support.requires("network") + #support.requires("network") - test_support.run_unittest(ProxyAuthTests) - test_support.run_unittest(TestUrlopen) + support.run_unittest(ProxyAuthTests) + support.run_unittest(TestUrlopen) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_urllib2net.py b/Lib/test/test_urllib2net.py index 75df9fd..89e48cb 100644 --- a/Lib/test/test_urllib2net.py +++ b/Lib/test/test_urllib2net.py @@ -1,7 +1,7 @@ #!/usr/bin/env python import unittest -from test import test_support +from test import support from test.test_urllib2 import sanepathname2url import socket @@ -105,7 +105,7 @@ class OtherNetworkTests(unittest.TestCase): self._test_urls(urls, self._extra_handlers()) def test_file(self): - TESTFN = test_support.TESTFN + TESTFN = support.TESTFN f = open(TESTFN, 'w') try: f.write('hi there\n') @@ -169,7 +169,7 @@ class OtherNetworkTests(unittest.TestCase): (expected_err, url, req, type(err), err)) self.assert_(isinstance(err, expected_err), msg) else: - with test_support.transient_internet(): + with support.transient_internet(): buf = f.read() f.close() debug("read %d bytes" % len(buf)) @@ -233,8 +233,8 @@ class TimeoutTest(unittest.TestCase): def test_main(): - test_support.requires("network") - test_support.run_unittest(AuthTests, + support.requires("network") + support.run_unittest(AuthTests, OtherNetworkTests, CloseSocketTest, TimeoutTest, diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py index 6fd4684..6c2632c 100644 --- a/Lib/test/test_urllibnet.py +++ b/Lib/test/test_urllibnet.py @@ -1,7 +1,7 @@ #!/usr/bin/env python import unittest -from test import test_support +from test import support import socket import urllib @@ -166,8 +166,8 @@ class urlretrieveNetworkTests(unittest.TestCase): def test_specified_path(self): # Make sure that specifying the location of the file to write to works. file_location,info = self.urlretrieve("http://www.python.org/", - test_support.TESTFN) - self.assertEqual(file_location, test_support.TESTFN) + support.TESTFN) + self.assertEqual(file_location, support.TESTFN) self.assert_(os.path.exists(file_location)) FILE = open(file_location, errors='ignore') try: @@ -186,8 +186,8 @@ class urlretrieveNetworkTests(unittest.TestCase): def test_main(): - test_support.requires('network') - test_support.run_unittest(URLTimeoutTest, + support.requires('network') + support.run_unittest(URLTimeoutTest, urlopenNetworkTests, urlretrieveNetworkTests) diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py index 8ab8f35..02b2f6f 100644 --- a/Lib/test/test_urlparse.py +++ b/Lib/test/test_urlparse.py @@ -1,6 +1,6 @@ #! /usr/bin/env python -from test import test_support +from test import support import unittest import urlparse @@ -311,7 +311,7 @@ class UrlParseTestCase(unittest.TestCase): ('http', 'example.com', '', '', 'blahblah=/foo', '')) def test_main(): - test_support.run_unittest(UrlParseTestCase) + support.run_unittest(UrlParseTestCase) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_userdict.py b/Lib/test/test_userdict.py index 3a8a8b4..30eec71 100644 --- a/Lib/test/test_userdict.py +++ b/Lib/test/test_userdict.py @@ -1,6 +1,6 @@ # Check every path through every method of UserDict -from test import test_support, mapping_tests +from test import support, mapping_tests import collections d0 = {} @@ -190,7 +190,7 @@ class UserDictTest(mapping_tests.TestHashMappingProtocol): def test_main(): - test_support.run_unittest( + support.run_unittest( UserDictTest, ) diff --git a/Lib/test/test_userlist.py b/Lib/test/test_userlist.py index a0daa4e..868ed24 100644 --- a/Lib/test/test_userlist.py +++ b/Lib/test/test_userlist.py @@ -1,7 +1,7 @@ # Check every path through every method of UserList from collections import UserList -from test import test_support, list_tests +from test import support, list_tests class UserListTest(list_tests.CommonTest): type2test = UserList @@ -53,7 +53,7 @@ class UserListTest(list_tests.CommonTest): self.assertEqual(next(iter(T((1,2)))), "0!!!") def test_main(): - test_support.run_unittest(UserListTest) + support.run_unittest(UserListTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_userstring.py b/Lib/test/test_userstring.py index e8fb135..0538138 100755 --- a/Lib/test/test_userstring.py +++ b/Lib/test/test_userstring.py @@ -3,7 +3,7 @@ # UserString instances should behave similar to builtin string objects. import string -from test import test_support, string_tests +from test import support, string_tests from collections import UserString @@ -43,7 +43,7 @@ class UserStringTest( def test_main(): - test_support.run_unittest(UserStringTest) + support.run_unittest(UserStringTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_uu.py b/Lib/test/test_uu.py index b4bb32b..02d0171 100644 --- a/Lib/test/test_uu.py +++ b/Lib/test/test_uu.py @@ -4,7 +4,7 @@ Nick Mathewson """ import unittest -from test import test_support +from test import support import sys, os import uu @@ -111,8 +111,8 @@ class UUFileTest(unittest.TestCase): pass def setUp(self): - self.tmpin = test_support.TESTFN + "i" - self.tmpout = test_support.TESTFN + "o" + self.tmpin = support.TESTFN + "i" + self.tmpout = support.TESTFN + "o" def tearDown(self): del self.tmpin @@ -121,7 +121,7 @@ class UUFileTest(unittest.TestCase): def test_encode(self): fin = fout = None try: - test_support.unlink(self.tmpin) + support.unlink(self.tmpin) fin = open(self.tmpin, 'wb') fin.write(plaintext) fin.close() @@ -151,7 +151,7 @@ class UUFileTest(unittest.TestCase): def test_decode(self): f = None try: - test_support.unlink(self.tmpin) + support.unlink(self.tmpin) f = open(self.tmpin, 'wb') f.write(encodedtextwrapped(0o644, self.tmpout)) f.close() @@ -185,7 +185,7 @@ class UUFileTest(unittest.TestCase): self._kill(f) def test_main(): - test_support.run_unittest(UUTest, + support.run_unittest(UUTest, UUStdIOTest, UUFileTest, ) diff --git a/Lib/test/test_uuid.py b/Lib/test/test_uuid.py index 92d6294..5a37c2f 100644 --- a/Lib/test/test_uuid.py +++ b/Lib/test/test_uuid.py @@ -1,5 +1,5 @@ from unittest import TestCase -from test import test_support +from test import support import uuid def importable(name): @@ -462,7 +462,7 @@ class TestUUID(TestCase): def test_main(): - test_support.run_unittest(TestUUID) + support.run_unittest(TestUUID) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_wait3.py b/Lib/test/test_wait3.py index 3adbec4..4cca441 100644 --- a/Lib/test/test_wait3.py +++ b/Lib/test/test_wait3.py @@ -4,7 +4,7 @@ import os import time from test.fork_wait import ForkWait -from test.test_support import TestSkipped, run_unittest, reap_children +from test.support import TestSkipped, run_unittest, reap_children try: os.fork diff --git a/Lib/test/test_wait4.py b/Lib/test/test_wait4.py index c85944d..192fd94 100644 --- a/Lib/test/test_wait4.py +++ b/Lib/test/test_wait4.py @@ -4,7 +4,7 @@ import os import time from test.fork_wait import ForkWait -from test.test_support import TestSkipped, run_unittest, reap_children +from test.support import TestSkipped, run_unittest, reap_children try: os.fork diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py index 7b512ef..6fb3c0e 100644 --- a/Lib/test/test_warnings.py +++ b/Lib/test/test_warnings.py @@ -4,7 +4,7 @@ import os from io import StringIO import sys import unittest -from test import test_support +from test import support from test import warning_tests @@ -72,21 +72,21 @@ class FilterTests(object): """Testing the filtering functionality.""" def test_error(self): - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: self.module.resetwarnings() self.module.filterwarnings("error", category=UserWarning) self.assertRaises(UserWarning, self.module.warn, "FilterTests.test_error") def test_ignore(self): - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: self.module.resetwarnings() self.module.filterwarnings("ignore", category=UserWarning) self.module.warn("FilterTests.test_ignore", UserWarning) self.assert_(not w.message) def test_always(self): - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: self.module.resetwarnings() self.module.filterwarnings("always", category=UserWarning) message = "FilterTests.test_always" @@ -97,7 +97,7 @@ class FilterTests(object): self.assert_(w.message, message) def test_default(self): - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: self.module.resetwarnings() self.module.filterwarnings("default", category=UserWarning) message = UserWarning("FilterTests.test_default") @@ -112,7 +112,7 @@ class FilterTests(object): raise ValueError("loop variant unhandled") def test_module(self): - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: self.module.resetwarnings() self.module.filterwarnings("module", category=UserWarning) message = UserWarning("FilterTests.test_module") @@ -123,7 +123,7 @@ class FilterTests(object): self.assert_(not w.message, "unexpected message: " + str(w)) def test_once(self): - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: self.module.resetwarnings() self.module.filterwarnings("once", category=UserWarning) message = UserWarning("FilterTests.test_once") @@ -139,14 +139,14 @@ class FilterTests(object): self.assert_(not w.message) def test_inheritance(self): - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: self.module.resetwarnings() self.module.filterwarnings("error", category=Warning) self.assertRaises(UserWarning, self.module.warn, "FilterTests.test_inheritance", UserWarning) def test_ordering(self): - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: self.module.resetwarnings() self.module.filterwarnings("ignore", category=UserWarning) self.module.filterwarnings("error", category=UserWarning, @@ -161,7 +161,7 @@ class FilterTests(object): def test_filterwarnings(self): # Test filterwarnings(). # Implicitly also tests resetwarnings(). - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: self.module.filterwarnings("error", "", Warning, "", 0) self.assertRaises(UserWarning, self.module.warn, 'convert to error') @@ -196,7 +196,7 @@ class WarnTests(unittest.TestCase): """Test warnings.warn() and warnings.warn_explicit().""" def test_message(self): - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: for i in range(4): text = 'multi %d' %i # Different text on each call. self.module.warn(text) @@ -205,7 +205,7 @@ class WarnTests(unittest.TestCase): def test_filename(self): with warnings_state(self.module): - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: warning_tests.inner("spam1") self.assertEqual(os.path.basename(w.filename), "warning_tests.py") warning_tests.outer("spam2") @@ -215,7 +215,7 @@ class WarnTests(unittest.TestCase): # Test stacklevel argument # make sure all messages are different, so the warning won't be skipped with warnings_state(self.module): - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: warning_tests.inner("spam3", stacklevel=1) self.assertEqual(os.path.basename(w.filename), "warning_tests.py") warning_tests.outer("spam4", stacklevel=1) @@ -238,7 +238,7 @@ class WarnTests(unittest.TestCase): try: del warning_tests.__file__ with warnings_state(self.module): - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: warning_tests.inner("spam8", stacklevel=1) self.assertEqual(w.filename, warning_tests.__name__) finally: @@ -255,7 +255,7 @@ class WarnTests(unittest.TestCase): del warning_tests.__file__ warning_tests.__name__ = '__main__' with warnings_state(self.module): - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: warning_tests.inner('spam9', stacklevel=1) self.assertEqual(w.filename, sys.argv[0]) finally: @@ -273,7 +273,7 @@ class WarnTests(unittest.TestCase): warning_tests.__name__ = '__main__' del sys.argv with warnings_state(self.module): - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: warning_tests.inner('spam10', stacklevel=1) self.assertEqual(w.filename, '__main__') finally: @@ -293,7 +293,7 @@ class WarnTests(unittest.TestCase): warning_tests.__name__ = '__main__' sys.argv = [''] with warnings_state(self.module): - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: warning_tests.inner('spam11', stacklevel=1) self.assertEqual(w.filename, '__main__') finally: @@ -315,7 +315,7 @@ class WCmdLineTests(unittest.TestCase): def test_improper_input(self): # Uses the private _setoption() function to test the parsing # of command-line warning arguments - with test_support.catch_warning(self.module): + with support.catch_warning(self.module): self.assertRaises(self.module._OptionError, self.module._setoption, '1:2:3:4:5:6') self.assertRaises(self.module._OptionError, @@ -340,7 +340,7 @@ class _WarningsTests(BaseTest): def test_filter(self): # Everything should function even if 'filters' is not in warnings. - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: self.module.filterwarnings("error", "", Warning, "", 0) self.assertRaises(UserWarning, self.module.warn, 'convert to error') @@ -355,7 +355,7 @@ class _WarningsTests(BaseTest): try: original_registry = self.module.onceregistry __warningregistry__ = {} - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: self.module.resetwarnings() self.module.filterwarnings("once", category=UserWarning) self.module.warn_explicit(message, UserWarning, "file", 42) @@ -380,10 +380,10 @@ class _WarningsTests(BaseTest): def test_showwarning_missing(self): # Test that showwarning() missing is okay. text = 'del showwarning test' - with test_support.catch_warning(self.module): + with support.catch_warning(self.module): self.module.filterwarnings("always", category=UserWarning) del self.module.showwarning - with test_support.captured_output('stderr') as stream: + with support.captured_output('stderr') as stream: self.module.warn(text) result = stream.getvalue() self.failUnless(text in result) @@ -401,10 +401,10 @@ class _WarningsTests(BaseTest): def test_show_warning_output(self): # With showarning() missing, make sure that output is okay. text = 'test show_warning' - with test_support.catch_warning(self.module): + with support.catch_warning(self.module): self.module.filterwarnings("always", category=UserWarning) del self.module.showwarning - with test_support.captured_output('stderr') as stream: + with support.captured_output('stderr') as stream: warning_tests.inner(text) result = stream.getvalue() self.failUnlessEqual(result.count('\n'), 2, @@ -476,7 +476,7 @@ class PyWarningsDisplayTests(BaseTest, WarningsDisplayTests): def test_main(): py_warnings.onceregistry.clear() c_warnings.onceregistry.clear() - test_support.run_unittest(CFilterTests, + support.run_unittest(CFilterTests, PyFilterTests, CWarnTests, PyWarnTests, diff --git a/Lib/test/test_wave.py b/Lib/test/test_wave.py index c37323a..a7746fd 100644 --- a/Lib/test/test_wave.py +++ b/Lib/test/test_wave.py @@ -1,4 +1,4 @@ -from test.test_support import TESTFN, run_unittest +from test.support import TESTFN, run_unittest import os import wave import unittest diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py index 7de7b77..303345b 100644 --- a/Lib/test/test_weakref.py +++ b/Lib/test/test_weakref.py @@ -4,7 +4,7 @@ import unittest import collections import weakref -from test import test_support +from test import support # Used in ReferencesTestCase.test_ref_created_during_del() . ref_from_del = None @@ -1145,13 +1145,13 @@ OK __test__ = {'libreftest' : libreftest} def test_main(): - test_support.run_unittest( + support.run_unittest( ReferencesTestCase, MappingTestCase, WeakValueDictionaryTestCase, WeakKeyDictionaryTestCase, ) - test_support.run_doctest(sys.modules[__name__]) + support.run_doctest(sys.modules[__name__]) if __name__ == "__main__": diff --git a/Lib/test/test_weakset.py b/Lib/test/test_weakset.py index 7f5b8eb..cff2045 100644 --- a/Lib/test/test_weakset.py +++ b/Lib/test/test_weakset.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support from weakref import proxy, ref, WeakSet import operator import copy @@ -306,7 +306,7 @@ class TestWeakSet(unittest.TestCase): def test_main(verbose=None): - test_support.run_unittest(TestWeakSet) + support.run_unittest(TestWeakSet) if __name__ == "__main__": test_main(verbose=True) diff --git a/Lib/test/test_whichdb.py b/Lib/test/test_whichdb.py index e63eb0f..d908ac5 100644 --- a/Lib/test/test_whichdb.py +++ b/Lib/test/test_whichdb.py @@ -4,14 +4,14 @@ """ import os -import test.test_support +import test.support import unittest import whichdb import anydbm import glob from test.test_anydbm import delete_files, dbm_iterator -_fname = test.test_support.TESTFN +_fname = test.support.TESTFN class WhichDBTestCase(unittest.TestCase): # Actual test methods are added to namespace @@ -27,7 +27,7 @@ class WhichDBTestCase(unittest.TestCase): name = module.__name__ if name == 'dumbdbm': continue # whichdb can't support dumbdbm - test.test_support.unlink(_fname) + test.support.unlink(_fname) f = module.open(_fname, 'c') f.close() self.assertEqual(name, whichdb.whichdb(_fname)) @@ -50,7 +50,7 @@ class WhichDBTestCase(unittest.TestCase): def test_main(): try: - test.test_support.run_unittest(WhichDBTestCase) + test.support.run_unittest(WhichDBTestCase) finally: delete_files() diff --git a/Lib/test/test_winreg.py b/Lib/test/test_winreg.py index 174d7bc..e852c69 100644 --- a/Lib/test/test_winreg.py +++ b/Lib/test/test_winreg.py @@ -6,7 +6,7 @@ from _winreg import * import os, sys import unittest -from test import test_support +from test import support test_key_name = "SOFTWARE\\Python Registry Test Key - Delete Me" @@ -161,7 +161,7 @@ class WinregTests(unittest.TestCase): self.assertEqual(r, os.environ["windir"] + "\\test") def test_main(): - test_support.run_unittest(WinregTests) + support.run_unittest(WinregTests) if __name__ == "__main__": try: diff --git a/Lib/test/test_winsound.py b/Lib/test/test_winsound.py index bc21d7e..c39a233 100644 --- a/Lib/test/test_winsound.py +++ b/Lib/test/test_winsound.py @@ -1,8 +1,8 @@ # Ridiculously simple test of the winsound module for Windows. import unittest -from test import test_support -test_support.requires('audio') +from test import support +support.requires('audio') import winsound, time import os import subprocess @@ -226,7 +226,7 @@ def _have_soundcard(): def test_main(): - test_support.run_unittest(BeepTest, MessageBeepTest, PlaySoundTest) + support.run_unittest(BeepTest, MessageBeepTest, PlaySoundTest) if __name__=="__main__": test_main() diff --git a/Lib/test/test_with.py b/Lib/test/test_with.py index 6e439ac..43f3271 100644 --- a/Lib/test/test_with.py +++ b/Lib/test/test_with.py @@ -10,7 +10,7 @@ import sys import unittest from collections import deque from contextlib import GeneratorContextManager, contextmanager -from test.test_support import run_unittest +from test.support import run_unittest class MockContextManager(GeneratorContextManager): diff --git a/Lib/test/test_wsgiref.py b/Lib/test/test_wsgiref.py index a5e0b27..ac5ada3 100755 --- a/Lib/test/test_wsgiref.py +++ b/Lib/test/test_wsgiref.py @@ -11,7 +11,7 @@ from io import StringIO, BytesIO, BufferedReader from socketserver import BaseServer import re, sys -from test import test_support +from test import support class MockServer(WSGIServer): """Non-socket HTTP server""" @@ -578,7 +578,7 @@ class HandlerTests(TestCase): # This epilogue is needed for compatibility with the Python 2.5 regrtest module def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_xdrlib.py b/Lib/test/test_xdrlib.py index 44d5a82..11a44ff 100644 --- a/Lib/test/test_xdrlib.py +++ b/Lib/test/test_xdrlib.py @@ -1,4 +1,4 @@ -from test import test_support +from test import support import unittest import xdrlib @@ -50,7 +50,7 @@ class XDRTest(unittest.TestCase): self.assertRaises(EOFError, up.unpack_uint) def test_main(): - test_support.run_unittest(XDRTest) + support.run_unittest(XDRTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py index 8470584..895902f 100644 --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -5,7 +5,7 @@ import doctest import sys -from test import test_support +from test import support SAMPLE_XML = """ @@ -345,7 +345,7 @@ def xinclude(): def test_main(): from test import test_xml_etree - test_support.run_doctest(test_xml_etree, verbosity=True) + support.run_doctest(test_xml_etree, verbosity=True) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_xml_etree_c.py b/Lib/test/test_xml_etree_c.py index 80e91d1..4d28d01 100644 --- a/Lib/test/test_xml_etree_c.py +++ b/Lib/test/test_xml_etree_c.py @@ -3,7 +3,7 @@ import doctest import sys -from test import test_support +from test import support from xml.etree import cElementTree as ET @@ -214,7 +214,7 @@ def bug_1534630(): def test_main(): from test import test_xml_etree_c - test_support.run_doctest(test_xml_etree_c, verbosity=True) + support.run_doctest(test_xml_etree_c, verbosity=True) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py index 7ff078d..cad2b9d 100644 --- a/Lib/test/test_xmlrpc.py +++ b/Lib/test/test_xmlrpc.py @@ -10,7 +10,7 @@ import mimetools import httplib import socket import os -from test import test_support +from test import support alist = [{'astring': 'foo@bar.baz.spam', 'afloat': 7283.43, @@ -546,20 +546,20 @@ class CGIHandlerTestCase(unittest.TestCase): # if the method is GET and no request_text is given, it runs handle_get # get sysout output tmp = sys.stdout - sys.stdout = open(test_support.TESTFN, "w") + sys.stdout = open(support.TESTFN, "w") self.cgi.handle_request() sys.stdout.close() sys.stdout = tmp # parse Status header - handle = open(test_support.TESTFN, "r").read() + handle = open(support.TESTFN, "r").read() status = handle.split()[1] message = ' '.join(handle.split()[2:4]) self.assertEqual(status, '400') self.assertEqual(message, 'Bad Request') - os.remove(test_support.TESTFN) + os.remove(support.TESTFN) os.environ['REQUEST_METHOD'] = '' def test_cgi_xmlrpc_response(self): @@ -581,7 +581,7 @@ class CGIHandlerTestCase(unittest.TestCase): tmp2 = sys.stdout sys.stdin = open("xmldata.txt", "r") - sys.stdout = open(test_support.TESTFN, "w") + sys.stdout = open(support.TESTFN, "w") self.cgi.handle_request() @@ -591,13 +591,13 @@ class CGIHandlerTestCase(unittest.TestCase): sys.stdout = tmp2 # will respond exception, if so, our goal is achieved ;) - handle = open(test_support.TESTFN, "r").read() + handle = open(support.TESTFN, "r").read() # start with 44th char so as not to get http header, we just need only xml self.assertRaises(xmlrpclib.Fault, xmlrpclib.loads, handle[44:]) os.remove("xmldata.txt") - os.remove(test_support.TESTFN) + os.remove(support.TESTFN) def test_main(): xmlrpc_tests = [XMLRPCTestCase, HelperTestCase, DateTimeTestCase, @@ -612,7 +612,7 @@ def test_main(): xmlrpc_tests.append(FailingServerTestCase) xmlrpc_tests.append(CGIHandlerTestCase) - test_support.run_unittest(*xmlrpc_tests) + support.run_unittest(*xmlrpc_tests) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_xmlrpc_net.py b/Lib/test/test_xmlrpc_net.py index e62fcb6..1f8dd5d 100644 --- a/Lib/test/test_xmlrpc_net.py +++ b/Lib/test/test_xmlrpc_net.py @@ -4,7 +4,7 @@ import errno import socket import sys import unittest -from test import test_support +from test import support import xmlrpclib @@ -37,8 +37,8 @@ class CurrentTimeTest(unittest.TestCase): def test_main(): - test_support.requires("network") - test_support.run_unittest(CurrentTimeTest) + support.requires("network") + support.run_unittest(CurrentTimeTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py index 6878262..30efeb9 100644 --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -8,8 +8,8 @@ import zipfile, os, unittest, sys, shutil, struct, io from tempfile import TemporaryFile from random import randint, random -import test.test_support as support -from test.test_support import TESTFN, run_unittest +import test.support as support +from test.support import TESTFN, run_unittest TESTFN2 = TESTFN + "2" FIXEDTEST_SIZE = 1000 diff --git a/Lib/test/test_zipfile64.py b/Lib/test/test_zipfile64.py index a008fd0..343fd4f 100644 --- a/Lib/test/test_zipfile64.py +++ b/Lib/test/test_zipfile64.py @@ -1,11 +1,11 @@ # Tests of the full ZIP64 functionality of zipfile -# The test_support.requires call is the only reason for keeping this separate +# The support.requires call is the only reason for keeping this separate # from test_zipfile -from test import test_support +from test import support # XXX(nnorwitz): disable this test by looking for extra largfile resource # which doesn't exist. This test takes over 30 minutes to run in general # and requires more disk space than most of the buildbots. -test_support.requires( +support.requires( 'extralargefile', 'test requires loads of disk-space bytes and a long time to run' ) @@ -23,7 +23,7 @@ import sys from io import StringIO from tempfile import TemporaryFile -from test.test_support import TESTFN, run_unittest +from test.support import TESTFN, run_unittest TESTFN2 = TESTFN + "2" diff --git a/Lib/test/test_zipimport.py b/Lib/test/test_zipimport.py index c7da859..754476a 100644 --- a/Lib/test/test_zipimport.py +++ b/Lib/test/test_zipimport.py @@ -8,7 +8,7 @@ import unittest import zlib # implied prerequisite from zipfile import ZipFile, ZipInfo, ZIP_STORED, ZIP_DEFLATED -from test import test_support +from test import support from test.test_importhooks import ImportHooksBaseTestCase, test_src, test_co import zipimport @@ -385,12 +385,12 @@ class BadFileZipImportTestCase(unittest.TestCase): self.assertZipFailure('A' * 33000) def testEmptyFile(self): - test_support.unlink(TESTMOD) + support.unlink(TESTMOD) open(TESTMOD, 'w+').close() self.assertZipFailure(TESTMOD) def testFileUnreadable(self): - test_support.unlink(TESTMOD) + support.unlink(TESTMOD) fd = os.open(TESTMOD, os.O_CREAT, 000) try: os.close(fd) @@ -399,10 +399,10 @@ class BadFileZipImportTestCase(unittest.TestCase): # If we leave "the read-only bit" set on Windows, nothing can # delete TESTMOD, and later tests suffer bogus failures. os.chmod(TESTMOD, 0o666) - test_support.unlink(TESTMOD) + support.unlink(TESTMOD) def testNotZipFile(self): - test_support.unlink(TESTMOD) + support.unlink(TESTMOD) fp = open(TESTMOD, 'w+') fp.write('a' * 22) fp.close() @@ -410,7 +410,7 @@ class BadFileZipImportTestCase(unittest.TestCase): # XXX: disabled until this works on Big-endian machines def _testBogusZipFile(self): - test_support.unlink(TESTMOD) + support.unlink(TESTMOD) fp = open(TESTMOD, 'w+') fp.write(struct.pack('=I', 0x06054B50)) fp.write('a' * 18) @@ -451,13 +451,13 @@ def cleanup(): def test_main(): cleanup() try: - test_support.run_unittest( + support.run_unittest( UncompressedZipImportTestCase, CompressedZipImportTestCase, BadFileZipImportTestCase, ) finally: - test_support.unlink(TESTMOD) + support.unlink(TESTMOD) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py index 4fa263d..485ffdc 100644 --- a/Lib/test/test_zlib.py +++ b/Lib/test/test_zlib.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support import zlib import binascii import random @@ -460,7 +460,7 @@ LAERTES def test_main(): - test_support.run_unittest( + support.run_unittest( ChecksumTestCase, ExceptionTestCase, CompressTestCase, diff --git a/Lib/test/xmltests.py b/Lib/test/xmltests.py index 446fe30..0bfcba1 100644 --- a/Lib/test/xmltests.py +++ b/Lib/test/xmltests.py @@ -2,9 +2,9 @@ # standard library. import sys -import test.test_support +import test.support -test.test_support.verbose = 0 +test.support.verbose = 0 def runtest(name): __import__(name) diff --git a/Misc/NEWS b/Misc/NEWS index 0e986c8..161485f 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -104,6 +104,8 @@ Library - pdb gained the "until" command. +- test.test_support has been renamed test.support + Build ----- -- cgit v0.12