Merged revisions 86542,87136,87216,87221,87228,87256,87337-87338,87372,87516,87571,88164 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r86542 | r.david.murray | 2010-11-19 22:48:58 -0500 (Fri, 19 Nov 2010) | 2 lines Make test class name unique so that both test classes run. ........ r87136 | r.david.murray | 2010-12-08 17:53:00 -0500 (Wed, 08 Dec 2010) | 6 lines Have script_helper._assert_python strip refcount strings from stderr. This makes the output of the function and those that depend on it independent of whether or not they are being run under a debug build. ........ r87216 | r.david.murray | 2010-12-13 17:50:30 -0500 (Mon, 13 Dec 2010) | 2 lines #10698: fix typo in example. ........ r87221 | r.david.murray | 2010-12-13 19:55:46 -0500 (Mon, 13 Dec 2010) | 4 lines #10699: fix docstring for tzset: it does not take a parameter Thanks to Garrett Cooper for the fix. ........ r87228 | r.david.murray | 2010-12-13 21:25:43 -0500 (Mon, 13 Dec 2010) | 2 lines Turn on regrtest -W (rerun immediately) option for Windows, too. ........ r87256 | r.david.murray | 2010-12-14 21:19:14 -0500 (Tue, 14 Dec 2010) | 2 lines #10705: document what the values of debuglevel are and mean. ........ r87337 | r.david.murray | 2010-12-17 11:11:40 -0500 (Fri, 17 Dec 2010) | 2 lines #10559: provide instructions for accessing sys.argv when first mentioned. ........ r87338 | r.david.murray | 2010-12-17 11:29:07 -0500 (Fri, 17 Dec 2010) | 2 lines #10454: clarify the compileall docs and help messages. [changes to compileall.py were not backported, only the doc changes] ........ r87372 | r.david.murray | 2010-12-18 11:39:06 -0500 (Sat, 18 Dec 2010) | 2 lines #10728: the default for printing help is sys.stdout, not stderr. ........ r87516 | r.david.murray | 2010-12-27 15:09:32 -0500 (Mon, 27 Dec 2010) | 5 lines #7056: runtest and runtest_inner don't use testdir, so drop it from their sigs I've only tested regular runs and -j runs. If I've broken anything else I'm sure I'll hear about it sooner or later. ........ r87571 | r.david.murray | 2010-12-29 14:06:48 -0500 (Wed, 29 Dec 2010) | 2 lines Fix same typo in docs. ........ r88164 | r.david.murray | 2011-01-24 14:34:58 -0500 (Mon, 24 Jan 2011) | 12 lines #10960: fix 'stat' links, link to lstat from stat, general tidy of stat doc. Original patch by Michal Nowikowski, with some additions and wording fixes by me. I changed the wording from 'Performs a stat system call' to 'Performs the equivalent of a stat system call', since on Windows there are no stat/lstat system calls involved. I also extended Michal's breakout of the attributes into a list to the other paragraphs, and rearranged the order of the paragraphs in the 'stat' docs to make it flow better and put it in what I think is a more logical/useful order. ........
This commit is contained in:
parent
730d12f0ca
commit
561b96f98c
|
@ -137,6 +137,7 @@ docs@python.org), and we'll be glad to correct the problem.
|
||||||
* Ross Moore
|
* Ross Moore
|
||||||
* Sjoerd Mullender
|
* Sjoerd Mullender
|
||||||
* Dale Nagata
|
* Dale Nagata
|
||||||
|
* Michal Nowikowski
|
||||||
* Ng Pheng Siong
|
* Ng Pheng Siong
|
||||||
* Koray Oner
|
* Koray Oner
|
||||||
* Tomas Oppelstrup
|
* Tomas Oppelstrup
|
||||||
|
|
|
@ -1654,14 +1654,14 @@ are available:
|
||||||
.. method:: ArgumentParser.print_usage(file=None)
|
.. method:: ArgumentParser.print_usage(file=None)
|
||||||
|
|
||||||
Print a brief description of how the :class:`ArgumentParser` should be
|
Print a brief description of how the :class:`ArgumentParser` should be
|
||||||
invoked on the command line. If *file* is ``None``, :data:`sys.stderr` is
|
invoked on the command line. If *file* is ``None``, :data:`sys.stdout` is
|
||||||
assumed.
|
assumed.
|
||||||
|
|
||||||
.. method:: ArgumentParser.print_help(file=None)
|
.. method:: ArgumentParser.print_help(file=None)
|
||||||
|
|
||||||
Print a help message, including the program usage and information about the
|
Print a help message, including the program usage and information about the
|
||||||
arguments registered with the :class:`ArgumentParser`. If *file* is
|
arguments registered with the :class:`ArgumentParser`. If *file* is
|
||||||
``None``, :data:`sys.stderr` is assumed.
|
``None``, :data:`sys.stdout` is assumed.
|
||||||
|
|
||||||
There are also variants of these methods that simply return a string instead of
|
There are also variants of these methods that simply return a string instead of
|
||||||
printing it:
|
printing it:
|
||||||
|
|
|
@ -6,9 +6,10 @@
|
||||||
|
|
||||||
|
|
||||||
This module provides some utility functions to support installing Python
|
This module provides some utility functions to support installing Python
|
||||||
libraries. These functions compile Python source files in a directory tree,
|
libraries. These functions compile Python source files in a directory tree.
|
||||||
allowing users without permission to write to the libraries to take advantage of
|
This module can be used to create the cached byte-code files at library
|
||||||
cached byte-code files.
|
installation time, which makes them available for use even by users who don't
|
||||||
|
have write permission to the library directories.
|
||||||
|
|
||||||
|
|
||||||
Command-line use
|
Command-line use
|
||||||
|
@ -27,7 +28,8 @@ compile Python sources.
|
||||||
|
|
||||||
.. cmdoption:: -l
|
.. cmdoption:: -l
|
||||||
|
|
||||||
Do not recurse.
|
Do not recurse into subdirectories, only compile source code files directly
|
||||||
|
contained in the named or implied directories.
|
||||||
|
|
||||||
.. cmdoption:: -f
|
.. cmdoption:: -f
|
||||||
|
|
||||||
|
@ -35,19 +37,26 @@ compile Python sources.
|
||||||
|
|
||||||
.. cmdoption:: -q
|
.. cmdoption:: -q
|
||||||
|
|
||||||
Do not print the list of files compiled.
|
Do not print the list of files compiled, print only error messages.
|
||||||
|
|
||||||
.. cmdoption:: -d destdir
|
.. cmdoption:: -d destdir
|
||||||
|
|
||||||
Purported directory name for error messages.
|
Directory prepended to the path to each file being compiled. This will
|
||||||
|
appear in compilation time tracebacks, and is also compiled in to the
|
||||||
|
byte-code file, where it will be used in tracebacks and other messages in
|
||||||
|
cases where the source file does not exist at the time the byte-code file is
|
||||||
|
executed.
|
||||||
|
|
||||||
.. cmdoption:: -x regex
|
.. cmdoption:: -x regex
|
||||||
|
|
||||||
Skip files with a full path that matches given regular expression.
|
regex is used to search the full path to each file considered for
|
||||||
|
compilation, and if the regex produces a match, the file is skipped.
|
||||||
|
|
||||||
.. cmdoption:: -i list
|
.. cmdoption:: -i list
|
||||||
|
|
||||||
Expand list with its content (file and directory names).
|
Read the file ``list`` and add each line that it contains to the list of
|
||||||
|
files and directories to compile. If ``list`` is ``-``, read lines from
|
||||||
|
``stdin``.
|
||||||
|
|
||||||
.. versionchanged:: 2.7
|
.. versionchanged:: 2.7
|
||||||
Added the ``-i`` option.
|
Added the ``-i`` option.
|
||||||
|
@ -59,31 +68,44 @@ Public functions
|
||||||
.. function:: compile_dir(dir[, maxlevels[, ddir[, force[, rx[, quiet]]]]])
|
.. function:: compile_dir(dir[, maxlevels[, ddir[, force[, rx[, quiet]]]]])
|
||||||
|
|
||||||
Recursively descend the directory tree named by *dir*, compiling all :file:`.py`
|
Recursively descend the directory tree named by *dir*, compiling all :file:`.py`
|
||||||
files along the way. The *maxlevels* parameter is used to limit the depth of
|
files along the way.
|
||||||
the recursion; it defaults to ``10``. If *ddir* is given, it is used as the
|
|
||||||
base path from which the filenames used in error messages will be generated.
|
The *maxlevels* parameter is used to limit the depth of the recursion; it
|
||||||
|
defaults to ``10``.
|
||||||
|
|
||||||
|
If *ddir* is given, it is prepended to the path to each file being compiled
|
||||||
|
for use in compilation time tracebacks, and is also compiled in to the
|
||||||
|
byte-code file, where it will be used in tracebacks and other messages in
|
||||||
|
cases where the source file does not exist at the time the byte-code file is
|
||||||
|
executed.
|
||||||
|
|
||||||
If *force* is true, modules are re-compiled even if the timestamps are up to
|
If *force* is true, modules are re-compiled even if the timestamps are up to
|
||||||
date.
|
date.
|
||||||
|
|
||||||
If *rx* is given, it specifies a regular expression of file names to exclude
|
If *rx* is given, its search method is called on the complete path to each
|
||||||
from the search; that expression is searched for in the full path.
|
file considered for compilation, and if it returns a true value, the file
|
||||||
|
is skipped.
|
||||||
|
|
||||||
If *quiet* is true, nothing is printed to the standard output in normal
|
If *quiet* is true, nothing is printed to the standard output unless errors
|
||||||
operation.
|
occur.
|
||||||
|
|
||||||
|
|
||||||
.. function:: compile_file(fullname[, ddir[, force[, rx[, quiet]]]])
|
.. function:: compile_file(fullname[, ddir[, force[, rx[, quiet]]]])
|
||||||
|
|
||||||
Compile the file with path *fullname*. If *ddir* is given, it is used as the
|
Compile the file with path *fullname*.
|
||||||
base path from which the filename used in error messages will be generated.
|
|
||||||
If *force* is true, modules are re-compiled even if the timestamp is up to
|
|
||||||
date.
|
|
||||||
|
|
||||||
If *rx* is given, it specifies a regular expression which, if matched, will
|
If *ddir* is given, it is prepended to the path to the file being compiled
|
||||||
prevent compilation; that expression is searched for in the full path.
|
for use in compilation time tracebacks, and is also compiled in to the
|
||||||
|
byte-code file, where it will be used in tracebacks and other messages in
|
||||||
|
cases where the source file does not exist at the time the byte-code file is
|
||||||
|
executed.
|
||||||
|
|
||||||
If *quiet* is true, nothing is printed to the standard output in normal
|
If *ra* is given, its search method is passed the full path name to the
|
||||||
operation.
|
file being compiled, and if it returns a true value, the file is not
|
||||||
|
compiled and ``True`` is returned.
|
||||||
|
|
||||||
|
If *quiet* is true, nothing is printed to the standard output unless errors
|
||||||
|
occur.
|
||||||
|
|
||||||
.. versionadded:: 2.7
|
.. versionadded:: 2.7
|
||||||
|
|
||||||
|
@ -91,9 +113,10 @@ Public functions
|
||||||
.. function:: compile_path([skip_curdir[, maxlevels[, force]]])
|
.. function:: compile_path([skip_curdir[, maxlevels[, force]]])
|
||||||
|
|
||||||
Byte-compile all the :file:`.py` files found along ``sys.path``. If
|
Byte-compile all the :file:`.py` files found along ``sys.path``. If
|
||||||
*skip_curdir* is true (the default), the current directory is not included in
|
*skip_curdir* is true (the default), the current directory is not included
|
||||||
the search. The *maxlevels* and *force* parameters default to ``0`` and are
|
in the search. All other parameters are passed to the :func:`compile_dir`
|
||||||
passed to the :func:`compile_dir` function.
|
function. Note that unlike the other compile functions, ``maxlevels``
|
||||||
|
defaults to ``0``.
|
||||||
|
|
||||||
To force a recompile of all the :file:`.py` files in the :file:`Lib/`
|
To force a recompile of all the :file:`.py` files in the :file:`Lib/`
|
||||||
subdirectory and all its subdirectories::
|
subdirectory and all its subdirectories::
|
||||||
|
|
|
@ -982,7 +982,7 @@ test module::
|
||||||
|
|
||||||
def load_tests(loader, tests, ignore):
|
def load_tests(loader, tests, ignore):
|
||||||
tests.addTests(doctest.DocTestSuite(my_module_with_doctests))
|
tests.addTests(doctest.DocTestSuite(my_module_with_doctests))
|
||||||
return test
|
return tests
|
||||||
|
|
||||||
There are two main functions for creating :class:`unittest.TestSuite` instances
|
There are two main functions for creating :class:`unittest.TestSuite` instances
|
||||||
from text files and modules with doctests:
|
from text files and modules with doctests:
|
||||||
|
|
|
@ -65,7 +65,7 @@ Here is the :class:`Header` class description:
|
||||||
character set is used both as *s*'s initial charset and as the default for
|
character set is used both as *s*'s initial charset and as the default for
|
||||||
subsequent :meth:`append` calls.
|
subsequent :meth:`append` calls.
|
||||||
|
|
||||||
The maximum line length can be specified explicit via *maxlinelen*. For
|
The maximum line length can be specified explicitly via *maxlinelen*. For
|
||||||
splitting the first line to a shorter value (to account for the field header
|
splitting the first line to a shorter value (to account for the field header
|
||||||
which isn't included in *s*, e.g. :mailheader:`Subject`) pass in the name of the
|
which isn't included in *s*, e.g. :mailheader:`Subject`) pass in the name of the
|
||||||
field in *header_name*. The default *maxlinelen* is 76, and the default value
|
field in *header_name*. The default *maxlinelen* is 76, and the default value
|
||||||
|
|
|
@ -674,7 +674,7 @@ as internal buffering of data.
|
||||||
|
|
||||||
.. function:: fstat(fd)
|
.. function:: fstat(fd)
|
||||||
|
|
||||||
Return status for file descriptor *fd*, like :func:`stat`.
|
Return status for file descriptor *fd*, like :func:`~os.stat`.
|
||||||
|
|
||||||
Availability: Unix, Windows.
|
Availability: Unix, Windows.
|
||||||
|
|
||||||
|
@ -1114,9 +1114,10 @@ Files and Directories
|
||||||
|
|
||||||
.. function:: lstat(path)
|
.. function:: lstat(path)
|
||||||
|
|
||||||
Like :func:`stat`, but do not follow symbolic links. This is an alias for
|
Perform the equivalent of an :c:func:`lstat` system call on the given path.
|
||||||
:func:`stat` on platforms that do not support symbolic links, such as
|
Similar to :func:`~os.stat`, but does not follow symbolic links. On
|
||||||
Windows.
|
platforms that do not support symbolic links, this is an alias for
|
||||||
|
:func:`~os.stat`.
|
||||||
|
|
||||||
|
|
||||||
.. function:: mkfifo(path[, mode])
|
.. function:: mkfifo(path[, mode])
|
||||||
|
@ -1314,23 +1315,23 @@ Files and Directories
|
||||||
|
|
||||||
.. function:: stat(path)
|
.. function:: stat(path)
|
||||||
|
|
||||||
Perform a :cfunc:`stat` system call on the given path. The return value is an
|
Perform the equivalent of a :c:func:`stat` system call on the given path.
|
||||||
object whose attributes correspond to the members of the :ctype:`stat`
|
(This function follows symlinks; to stat a symlink use :func:`lstat`.)
|
||||||
structure, namely: :attr:`st_mode` (protection bits), :attr:`st_ino` (inode
|
|
||||||
number), :attr:`st_dev` (device), :attr:`st_nlink` (number of hard links),
|
|
||||||
:attr:`st_uid` (user id of owner), :attr:`st_gid` (group id of owner),
|
|
||||||
:attr:`st_size` (size of file, in bytes), :attr:`st_atime` (time of most recent
|
|
||||||
access), :attr:`st_mtime` (time of most recent content modification),
|
|
||||||
:attr:`st_ctime` (platform dependent; time of most recent metadata change on
|
|
||||||
Unix, or the time of creation on Windows)::
|
|
||||||
|
|
||||||
>>> import os
|
The return value is an object whose attributes correspond to the members
|
||||||
>>> statinfo = os.stat('somefile.txt')
|
of the :c:type:`stat` structure, namely:
|
||||||
>>> statinfo
|
|
||||||
(33188, 422511L, 769L, 1, 1032, 100, 926L, 1105022698,1105022732, 1105022732)
|
* :attr:`st_mode` - protection bits,
|
||||||
>>> statinfo.st_size
|
* :attr:`st_ino` - inode number,
|
||||||
926L
|
* :attr:`st_dev` - device,
|
||||||
>>>
|
* :attr:`st_nlink` - number of hard links,
|
||||||
|
* :attr:`st_uid` - user id of owner,
|
||||||
|
* :attr:`st_gid` - group id of owner,
|
||||||
|
* :attr:`st_size` - size of file, in bytes,
|
||||||
|
* :attr:`st_atime` - time of most recent access,
|
||||||
|
* :attr:`st_mtime` - time of most recent content modification,
|
||||||
|
* :attr:`st_ctime` - platform dependent; time of most recent metadata change on
|
||||||
|
Unix, or the time of creation on Windows)
|
||||||
|
|
||||||
.. versionchanged:: 2.3
|
.. versionchanged:: 2.3
|
||||||
If :func:`stat_float_times` returns ``True``, the time values are floats, measuring
|
If :func:`stat_float_times` returns ``True``, the time values are floats, measuring
|
||||||
|
@ -1339,31 +1340,30 @@ Files and Directories
|
||||||
discussion.
|
discussion.
|
||||||
|
|
||||||
On some Unix systems (such as Linux), the following attributes may also be
|
On some Unix systems (such as Linux), the following attributes may also be
|
||||||
available: :attr:`st_blocks` (number of blocks allocated for file),
|
available:
|
||||||
:attr:`st_blksize` (filesystem blocksize), :attr:`st_rdev` (type of device if an
|
|
||||||
inode device). :attr:`st_flags` (user defined flags for file).
|
* :attr:`st_blocks` - number of blocks allocated for file
|
||||||
|
* :attr:`st_blksize` - filesystem blocksize
|
||||||
|
* :attr:`st_rdev` - type of device if an inode device
|
||||||
|
* :attr:`st_flags` - user defined flags for file
|
||||||
|
|
||||||
On other Unix systems (such as FreeBSD), the following attributes may be
|
On other Unix systems (such as FreeBSD), the following attributes may be
|
||||||
available (but may be only filled out if root tries to use them): :attr:`st_gen`
|
available (but may be only filled out if root tries to use them):
|
||||||
(file generation number), :attr:`st_birthtime` (time of file creation).
|
|
||||||
|
* :attr:`st_gen` - file generation number
|
||||||
|
* :attr:`st_birthtime` - time of file creation
|
||||||
|
|
||||||
On Mac OS systems, the following attributes may also be available:
|
On Mac OS systems, the following attributes may also be available:
|
||||||
:attr:`st_rsize`, :attr:`st_creator`, :attr:`st_type`.
|
|
||||||
|
|
||||||
On RISCOS systems, the following attributes are also available: :attr:`st_ftype`
|
* :attr:`st_rsize`
|
||||||
(file type), :attr:`st_attrs` (attributes), :attr:`st_obtype` (object type).
|
* :attr:`st_creator`
|
||||||
|
* :attr:`st_type`
|
||||||
|
|
||||||
.. index:: module: stat
|
On RISCOS systems, the following attributes are also available:
|
||||||
|
|
||||||
For backward compatibility, the return value of :func:`stat` is also accessible
|
* :attr:`st_ftype` (file type)
|
||||||
as a tuple of at least 10 integers giving the most important (and portable)
|
* :attr:`st_attrs` (attributes)
|
||||||
members of the :ctype:`stat` structure, in the order :attr:`st_mode`,
|
* :attr:`st_obtype` (object type).
|
||||||
:attr:`st_ino`, :attr:`st_dev`, :attr:`st_nlink`, :attr:`st_uid`,
|
|
||||||
:attr:`st_gid`, :attr:`st_size`, :attr:`st_atime`, :attr:`st_mtime`,
|
|
||||||
:attr:`st_ctime`. More items may be added at the end by some implementations.
|
|
||||||
The standard module :mod:`stat` defines functions and constants that are useful
|
|
||||||
for extracting information from a :ctype:`stat` structure. (On Windows, some
|
|
||||||
items are filled with dummy values.)
|
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
|
@ -1373,6 +1373,28 @@ Files and Directories
|
||||||
:attr:`st_mtime` has 2-second resolution, and :attr:`st_atime` has only 1-day
|
:attr:`st_mtime` has 2-second resolution, and :attr:`st_atime` has only 1-day
|
||||||
resolution. See your operating system documentation for details.
|
resolution. See your operating system documentation for details.
|
||||||
|
|
||||||
|
For backward compatibility, the return value of :func:`~os.stat` is also accessible
|
||||||
|
as a tuple of at least 10 integers giving the most important (and portable)
|
||||||
|
members of the :ctype:`stat` structure, in the order :attr:`st_mode`,
|
||||||
|
:attr:`st_ino`, :attr:`st_dev`, :attr:`st_nlink`, :attr:`st_uid`,
|
||||||
|
:attr:`st_gid`, :attr:`st_size`, :attr:`st_atime`, :attr:`st_mtime`,
|
||||||
|
:attr:`st_ctime`. More items may be added at the end by some implementations.
|
||||||
|
|
||||||
|
.. index:: module: stat
|
||||||
|
|
||||||
|
The standard module :mod:`stat` defines functions and constants that are useful
|
||||||
|
for extracting information from a :ctype:`stat` structure. (On Windows, some
|
||||||
|
items are filled with dummy values.)
|
||||||
|
|
||||||
|
Example::
|
||||||
|
|
||||||
|
>>> import os
|
||||||
|
>>> statinfo = os.stat('somefile.txt')
|
||||||
|
>>> statinfo
|
||||||
|
(33188, 422511, 769, 1, 1032, 100, 926, 1105022698,1105022732, 1105022732)
|
||||||
|
>>> statinfo.st_size
|
||||||
|
926
|
||||||
|
|
||||||
Availability: Unix, Windows.
|
Availability: Unix, Windows.
|
||||||
|
|
||||||
.. versionchanged:: 2.2
|
.. versionchanged:: 2.2
|
||||||
|
@ -1385,7 +1407,7 @@ Files and Directories
|
||||||
.. function:: stat_float_times([newvalue])
|
.. function:: stat_float_times([newvalue])
|
||||||
|
|
||||||
Determine whether :class:`stat_result` represents time stamps as float objects.
|
Determine whether :class:`stat_result` represents time stamps as float objects.
|
||||||
If *newvalue* is ``True``, future calls to :func:`stat` return floats, if it is
|
If *newvalue* is ``True``, future calls to :func:`~os.stat` return floats, if it is
|
||||||
``False``, future calls return ints. If *newvalue* is omitted, return the
|
``False``, future calls return ints. If *newvalue* is omitted, return the
|
||||||
current setting.
|
current setting.
|
||||||
|
|
||||||
|
@ -1505,8 +1527,8 @@ Files and Directories
|
||||||
respectively. Whether a directory can be given for *path* depends on whether
|
respectively. Whether a directory can be given for *path* depends on whether
|
||||||
the operating system implements directories as files (for example, Windows
|
the operating system implements directories as files (for example, Windows
|
||||||
does not). Note that the exact times you set here may not be returned by a
|
does not). Note that the exact times you set here may not be returned by a
|
||||||
subsequent :func:`stat` call, depending on the resolution with which your
|
subsequent :func:`~os.stat` call, depending on the resolution with which your
|
||||||
operating system records access and modification times; see :func:`stat`.
|
operating system records access and modification times; see :func:`~os.stat`.
|
||||||
|
|
||||||
.. versionchanged:: 2.0
|
.. versionchanged:: 2.0
|
||||||
Added support for ``None`` for *times*.
|
Added support for ``None`` for *times*.
|
||||||
|
|
|
@ -78,8 +78,9 @@ Argument Passing
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
When known to the interpreter, the script name and additional arguments
|
When known to the interpreter, the script name and additional arguments
|
||||||
thereafter are passed to the script in the variable ``sys.argv``, which is a
|
thereafter are turned into a list of strings and assigned to the ``argv``
|
||||||
list of strings. Its length is at least one; when no script and no arguments
|
variable in the ``sys`` module. You can access this list by executing ``import
|
||||||
|
sys``. The length of the list is at least one; when no script and no arguments
|
||||||
are given, ``sys.argv[0]`` is an empty string. When the script name is given as
|
are given, ``sys.argv[0]`` is an empty string. When the script name is given as
|
||||||
``'-'`` (meaning standard input), ``sys.argv[0]`` is set to ``'-'``. When
|
``'-'`` (meaning standard input), ``sys.argv[0]`` is set to ``'-'``. When
|
||||||
:option:`-c` *command* is used, ``sys.argv[0]`` is set to ``'-c'``. When
|
:option:`-c` *command* is used, ``sys.argv[0]`` is set to ``'-c'``. When
|
||||||
|
|
|
@ -490,7 +490,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
|
||||||
def tests_and_args():
|
def tests_and_args():
|
||||||
for test in tests:
|
for test in tests:
|
||||||
args_tuple = (
|
args_tuple = (
|
||||||
(test, verbose, quiet, testdir),
|
(test, verbose, quiet),
|
||||||
dict(huntrleaks=huntrleaks, use_resources=use_resources)
|
dict(huntrleaks=huntrleaks, use_resources=use_resources)
|
||||||
)
|
)
|
||||||
yield (test, args_tuple)
|
yield (test, args_tuple)
|
||||||
|
@ -557,16 +557,15 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
|
||||||
if trace:
|
if trace:
|
||||||
# If we're tracing code coverage, then we don't exit with status
|
# If we're tracing code coverage, then we don't exit with status
|
||||||
# if on a false return value from main.
|
# if on a false return value from main.
|
||||||
tracer.runctx('runtest(test, verbose, quiet, testdir)',
|
tracer.runctx('runtest(test, verbose, quiet)',
|
||||||
globals=globals(), locals=vars())
|
globals=globals(), locals=vars())
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
result = runtest(test, verbose, quiet,
|
result = runtest(test, verbose, quiet, huntrleaks)
|
||||||
testdir, huntrleaks)
|
|
||||||
accumulate_result(test, result)
|
accumulate_result(test, result)
|
||||||
if verbose3 and result[0] == FAILED:
|
if verbose3 and result[0] == FAILED:
|
||||||
print "Re-running test %r in verbose mode" % test
|
print "Re-running test %r in verbose mode" % test
|
||||||
runtest(test, True, quiet, testdir, huntrleaks)
|
runtest(test, True, quiet, huntrleaks)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
interrupted = True
|
interrupted = True
|
||||||
break
|
break
|
||||||
|
@ -636,8 +635,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
try:
|
try:
|
||||||
test_support.verbose = True
|
test_support.verbose = True
|
||||||
ok = runtest(test, True, quiet, testdir,
|
ok = runtest(test, True, quiet, huntrleaks)
|
||||||
huntrleaks)
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
# print a newline separate from the ^C
|
# print a newline separate from the ^C
|
||||||
print
|
print
|
||||||
|
@ -693,14 +691,13 @@ def findtests(testdir=None, stdtests=STDTESTS, nottests=NOTTESTS):
|
||||||
return stdtests + sorted(tests)
|
return stdtests + sorted(tests)
|
||||||
|
|
||||||
def runtest(test, verbose, quiet,
|
def runtest(test, verbose, quiet,
|
||||||
testdir=None, huntrleaks=False, use_resources=None):
|
huntrleaks=False, use_resources=None):
|
||||||
"""Run a single test.
|
"""Run a single test.
|
||||||
|
|
||||||
test -- the name of the test
|
test -- the name of the test
|
||||||
verbose -- if true, print more messages
|
verbose -- if true, print more messages
|
||||||
quiet -- if true, don't print 'skipped' messages (probably redundant)
|
quiet -- if true, don't print 'skipped' messages (probably redundant)
|
||||||
test_times -- a list of (time, test_name) pairs
|
test_times -- a list of (time, test_name) pairs
|
||||||
testdir -- test directory
|
|
||||||
huntrleaks -- run multiple times to test for leaks; requires a debug
|
huntrleaks -- run multiple times to test for leaks; requires a debug
|
||||||
build; a triple corresponding to -R's three arguments
|
build; a triple corresponding to -R's three arguments
|
||||||
Returns one of the test result constants:
|
Returns one of the test result constants:
|
||||||
|
@ -716,8 +713,7 @@ def runtest(test, verbose, quiet,
|
||||||
if use_resources is not None:
|
if use_resources is not None:
|
||||||
test_support.use_resources = use_resources
|
test_support.use_resources = use_resources
|
||||||
try:
|
try:
|
||||||
return runtest_inner(test, verbose, quiet,
|
return runtest_inner(test, verbose, quiet, huntrleaks)
|
||||||
testdir, huntrleaks)
|
|
||||||
finally:
|
finally:
|
||||||
cleanup_test_droppings(test, verbose)
|
cleanup_test_droppings(test, verbose)
|
||||||
|
|
||||||
|
@ -850,10 +846,8 @@ class saved_test_environment:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def runtest_inner(test, verbose, quiet,
|
def runtest_inner(test, verbose, quiet, huntrleaks=False):
|
||||||
testdir=None, huntrleaks=False):
|
|
||||||
test_support.unload(test)
|
test_support.unload(test)
|
||||||
testdir = findtestdir(testdir)
|
|
||||||
if verbose:
|
if verbose:
|
||||||
capture_stdout = None
|
capture_stdout = None
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import os.path
|
import os.path
|
||||||
import tempfile
|
import tempfile
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -11,6 +12,8 @@ import contextlib
|
||||||
import shutil
|
import shutil
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
|
from test.test_support import strip_python_stderr
|
||||||
|
|
||||||
# Executing the interpreter in a subprocess
|
# Executing the interpreter in a subprocess
|
||||||
def _assert_python(expected_success, *args, **env_vars):
|
def _assert_python(expected_success, *args, **env_vars):
|
||||||
cmd_line = [sys.executable]
|
cmd_line = [sys.executable]
|
||||||
|
@ -31,6 +34,7 @@ def _assert_python(expected_success, *args, **env_vars):
|
||||||
p.stdout.close()
|
p.stdout.close()
|
||||||
p.stderr.close()
|
p.stderr.close()
|
||||||
rc = p.returncode
|
rc = p.returncode
|
||||||
|
err = strip_python_stderr(err)
|
||||||
if (rc and expected_success) or (not rc and not expected_success):
|
if (rc and expected_success) or (not rc and not expected_success):
|
||||||
raise AssertionError(
|
raise AssertionError(
|
||||||
"Process return code is %d, "
|
"Process return code is %d, "
|
||||||
|
|
|
@ -4317,7 +4317,7 @@ class TestArgumentError(TestCase):
|
||||||
# ArgumentTypeError tests
|
# ArgumentTypeError tests
|
||||||
# =======================
|
# =======================
|
||||||
|
|
||||||
class TestArgumentError(TestCase):
|
class TestArgumentTypeError(TestCase):
|
||||||
|
|
||||||
def test_argument_type_error(self):
|
def test_argument_type_error(self):
|
||||||
|
|
||||||
|
|
|
@ -671,7 +671,7 @@ time_tzset(PyObject *self, PyObject *unused)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(tzset_doc,
|
PyDoc_STRVAR(tzset_doc,
|
||||||
"tzset(zone)\n\
|
"tzset()\n\
|
||||||
\n\
|
\n\
|
||||||
Initialize, or reinitialize, the local timezone to the value stored in\n\
|
Initialize, or reinitialize, the local timezone to the value stored in\n\
|
||||||
os.environ['TZ']. The TZ environment variable should be specified in\n\
|
os.environ['TZ']. The TZ environment variable should be specified in\n\
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
@rem Used by the buildbot "test" step.
|
@rem Used by the buildbot "test" step.
|
||||||
cd PCbuild
|
cd PCbuild
|
||||||
call rt.bat -d -q -uall -rw
|
call rt.bat -d -q -uall -rwW
|
||||||
|
|
Loading…
Reference in New Issue