Skip to content

Commit

Permalink
Merged revisions 70768,71657,71721,71729,71794,71976,72036-72037,7207…
Browse files Browse the repository at this point in the history
…9,72085,72131-72134,72191,72197-72198,72219,72221,72225,72303,72434,72467,72476 via svnmerge from

svn+ssh://[email protected]/python/trunk

........
  r70768 | andrew.kuchling | 2009-03-30 17:29:15 -0500 (Mon, 30 Mar 2009) | 1 line

  Typo fixes
........
  r71657 | vinay.sajip | 2009-04-16 14:07:37 -0500 (Thu, 16 Apr 2009) | 1 line

  Issue python#5768: Change to Unicode output logic and test case for same.
........
  r71721 | benjamin.peterson | 2009-04-18 14:26:19 -0500 (Sat, 18 Apr 2009) | 1 line

  fix a few nits in unittest.py python#5771
........
  r71729 | benjamin.peterson | 2009-04-18 16:03:10 -0500 (Sat, 18 Apr 2009) | 1 line

  move test to a more appropiate one
........
  r71794 | vinay.sajip | 2009-04-22 07:10:47 -0500 (Wed, 22 Apr 2009) | 2 lines

  Issue python#5170: Fixed regression caused when fixing python#5768.
........
  r71976 | mark.dickinson | 2009-04-26 14:54:55 -0500 (Sun, 26 Apr 2009) | 2 lines

  Fix typo in function name
........
  r72036 | georg.brandl | 2009-04-27 12:04:23 -0500 (Mon, 27 Apr 2009) | 1 line

  python#5848: small unittest doc patch.
........
  r72037 | georg.brandl | 2009-04-27 12:09:53 -0500 (Mon, 27 Apr 2009) | 1 line

  python#5840: dont claim we dont support TLS.
........
  r72079 | r.david.murray | 2009-04-28 14:02:55 -0500 (Tue, 28 Apr 2009) | 2 lines

  Remove spurious 'u'.
........
  r72085 | georg.brandl | 2009-04-28 16:48:35 -0500 (Tue, 28 Apr 2009) | 1 line

  Make the doctests in the docs pass, except for those in the turtle module.
........
  r72131 | benjamin.peterson | 2009-04-29 17:43:35 -0500 (Wed, 29 Apr 2009) | 1 line

  fix test_shutil on ZFS python#5676
........
  r72132 | georg.brandl | 2009-04-29 17:44:07 -0500 (Wed, 29 Apr 2009) | 1 line

  python#5878: fix repr of re object.
........
  r72133 | benjamin.peterson | 2009-04-29 17:44:15 -0500 (Wed, 29 Apr 2009) | 1 line

  make sure mode is removable while cleaning up test droppings
........
  r72134 | benjamin.peterson | 2009-04-29 19:06:33 -0500 (Wed, 29 Apr 2009) | 1 line

  make sure to close file
........
  r72191 | michael.foord | 2009-05-02 06:43:06 -0500 (Sat, 02 May 2009) | 9 lines

  Adds an exit parameter to unittest.main(). If False main no longer
  calls sys.exit.

  Closes issue 3379.

  Michael Foord

........
  r72197 | benjamin.peterson | 2009-05-02 11:24:37 -0500 (Sat, 02 May 2009) | 1 line

  don't let sys.argv be used in the tests
........
  r72198 | andrew.kuchling | 2009-05-02 12:12:15 -0500 (Sat, 02 May 2009) | 1 line

  Add items
........
  r72219 | michael.foord | 2009-05-02 15:15:05 -0500 (Sat, 02 May 2009) | 8 lines

  Add addCleanup and doCleanups to unittest.TestCase.

  Closes issue 5679.

  Michael Foord
........
  r72221 | benjamin.peterson | 2009-05-02 15:26:53 -0500 (Sat, 02 May 2009) | 1 line

  add myself
........
  r72225 | michael.foord | 2009-05-02 17:43:34 -0500 (Sat, 02 May 2009) | 1 line
........
  r72303 | benjamin.peterson | 2009-05-04 19:55:24 -0500 (Mon, 04 May 2009) | 1 line

  using sys._getframe(x), where x > 0 doesnt' work on IronPython
........
  r72434 | r.david.murray | 2009-05-07 13:09:58 -0500 (Thu, 07 May 2009) | 2 lines

  Pre-opened test file needs to be opened in binary mode.
........
  r72467 | georg.brandl | 2009-05-08 07:17:34 -0500 (Fri, 08 May 2009) | 1 line

  Fix name.
........
  r72476 | thomas.heller | 2009-05-08 15:09:40 -0500 (Fri, 08 May 2009) | 4 lines

  Add a file that contains diffs between offical libffi files and the
  files in this repository.  Should make it easier to merge new libffi
  versions.
........
  • Loading branch information
benjaminp committed May 8, 2009
1 parent 8a282d1 commit 25c95f1
Show file tree
Hide file tree
Showing 22 changed files with 910 additions and 146 deletions.
7 changes: 3 additions & 4 deletions Doc/c-api/init.rst
Original file line number Diff line number Diff line change
Expand Up @@ -416,10 +416,9 @@ the I/O is waiting for the I/O operation to complete.
The Python interpreter needs to keep some bookkeeping information separate per
thread --- for this it uses a data structure called :ctype:`PyThreadState`.
There's one global variable, however: the pointer to the current
:ctype:`PyThreadState` structure. While most thread packages have a way to
store "per-thread global data," Python's internal platform independent thread
abstraction doesn't support this yet. Therefore, the current thread state must
be manipulated explicitly.
:ctype:`PyThreadState` structure. Before the addition of :dfn:`thread-local
storage` (:dfn:`TLS`) the current thread state had to be manipulated
explicitly.

This is easy enough in most cases. Most code manipulating the global
interpreter lock has the following simple structure::
Expand Down
2 changes: 1 addition & 1 deletion Doc/howto/functional.rst
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ Here's a sample usage of the ``generate_ints()`` generator:

>>> gen = generate_ints(3)
>>> gen
<generator object at ...>
<generator object generate_ints at ...>
>>> next(gen)
0
>>> next(gen)
Expand Down
2 changes: 1 addition & 1 deletion Doc/howto/regex.rst
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ performing string substitutions. ::
>>> import re
>>> p = re.compile('ab*')
>>> p
<re.RegexObject instance at 80b4150>
<_sre.SRE_Pattern object at 80b4150>

:func:`re.compile` also accepts an optional *flags* argument, used to enable
various special features and syntax variations. We'll go over the available
Expand Down
1 change: 1 addition & 0 deletions Doc/library/2to3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ and off individually. They are described here in more detail.
:synopsis: the 2to3 library
.. moduleauthor:: Guido van Rossum
.. moduleauthor:: Collin Winter
.. moduleauthor:: Benjamin Peterson <[email protected]>


.. note::
Expand Down
6 changes: 3 additions & 3 deletions Doc/library/collections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,15 @@ For example::
class is similar to bags or multisets in other languages.

Elements are counted from an *iterable* or initialized from another
*mapping* (or counter)::
*mapping* (or counter):

>>> c = Counter() # a new, empty counter
>>> c = Counter('gallahad') # a new counter from an iterable
>>> c = Counter({'red': 4, 'blue': 2}) # a new counter from a mapping
>>> c = Counter(cats=4, dogs=8) # a new counter from keyword args

Counter objects have a dictionary interface except that they return a zero
count for missing items instead of raising a :exc:`KeyError`::
count for missing items instead of raising a :exc:`KeyError`:

>>> c = Counter(['eggs', 'ham'])
>>> c['bacon'] # count of a missing element is zero
Expand Down Expand Up @@ -210,7 +210,7 @@ For example::
Return a list of the *n* most common elements and their counts from the
most common to the least. If *n* is not specified, :func:`most_common`
returns *all* elements in the counter. Elements with equal counts are
ordered arbitrarily::
ordered arbitrarily:

>>> Counter('abracadabra').most_common(3)
[('a', 5), ('r', 2), ('b', 2)]
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/decimal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1746,7 +1746,7 @@ the :const:`Inexact` trap is set, it is also useful for validation:
>>> Decimal('3.214').quantize(TWOPLACES, context=Context(traps=[Inexact]))
Traceback (most recent call last):
...
Inexact
Inexact: None

Q. Once I have valid two place inputs, how do I maintain that invariant
throughout an application?
Expand Down
4 changes: 2 additions & 2 deletions Doc/library/json.rst
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,12 @@ Basic Usage
document) to a Python object.

*object_hook* is an optional function that will be called with the result of
any object literal decode (a :class:`dict`). The return value of
any object literal decoded (a :class:`dict`). The return value of
*object_hook* will be used instead of the :class:`dict`. This feature can be used
to implement custom decoders (e.g. JSON-RPC class hinting).

*object_pairs_hook* is an optional function that will be called with the
result of any object literal decode with an ordered list of pairs. The
result of any object literal decoded with an ordered list of pairs. The
return value of *object_pairs_hook* will be used instead of the
:class:`dict`. This feature can be used to implement custom decoders that
rely on the order that the key and value pairs are decoded (for example,
Expand Down
3 changes: 1 addition & 2 deletions Doc/library/shelve.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

:mod:`shelve` --- Python object persistence
===========================================

Expand Down Expand Up @@ -35,7 +34,7 @@ lots of shared sub-objects. The keys are ordinary strings.
accessed entries are written back (there is no way to determine which accessed
entries are mutable, nor which ones were actually mutated).

Shelve objects support all methods supported by dictionaries. This eases the
Shelf objects support all methods supported by dictionaries. This eases the
transition from dictionary based scripts to those requiring persistent storage.

One additional method is supported:
Expand Down
4 changes: 2 additions & 2 deletions Doc/library/subprocess.rst
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,13 @@ This module also defines four shortcut functions:
:attr:`returncode`
attribute and output in the :attr:`output` attribute.

The arguments are the same as for the :class:`Popen` constructor. Example:
The arguments are the same as for the :class:`Popen` constructor. Example::

>>> subprocess.check_output(["ls", "-l", "/dev/null"])
'crw-rw-rw- 1 root root 1, 3 Oct 18 2007 /dev/null\n'

The stdout argument is not allowed as it is used internally.
To capture standard error in the result, use stderr=subprocess.STDOUT.
To capture standard error in the result, use ``stderr=subprocess.STDOUT``::

>>> subprocess.check_output(
["/bin/sh", "-c", "ls non_existent_file ; exit 0"],
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/traceback.rst
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ The output for the example would look similar to this:
*** extract_tb:
[('<doctest...>', 10, '<module>', 'lumberjack()'),
('<doctest...>', 4, 'lumberjack', 'bright_side_of_death()'),
(u'<doctest...>', 7, 'bright_side_of_death', 'return tuple()[0]')]
('<doctest...>', 7, 'bright_side_of_death', 'return tuple()[0]')]
*** format_tb:
[' File "<doctest...>", line 10, in <module>\n lumberjack()\n',
' File "<doctest...>", line 4, in lumberjack\n bright_side_of_death()\n',
Expand Down
84 changes: 80 additions & 4 deletions Doc/library/unittest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,6 @@ Test cases
along with the method name.

.. versionchanged:: 3.1

In earlier versions this only returned the first line of the test
method's docstring, if available or the :const:`None`. That led to
undesirable behavior of not printing the test name when someone was
Expand All @@ -978,6 +977,36 @@ Test cases
.. versionadded:: 3.1


.. method:: addCleanup(function[, *args[, **kwargs]])

Add a function to be called after :meth:`tearDown` to cleanup resources
used during the test. Functions will be called in reverse order to the
order they are added (LIFO). They are called with any arguments and
keyword arguments passed into :meth:`addCleanup` when they are
added.

If :meth:`setUp` fails, meaning that :meth:`tearDown` is not called,
then any cleanup functions added will still be called.

.. versionadded:: 2.7


.. method:: doCleanups()

This method is called uncoditionally after :meth:`tearDown`, or
after :meth:`setUp` if :meth:`setUp` raises an exception.

It is responsible for calling all the cleanup functions added by
:meth:`addCleanup`. If you need cleanup functions to be called
*prior* to :meth:`tearDown` then you can call :meth:`doCleanups`
yourself.

:meth:`doCleanups` pops methods off the stack of cleanup
functions one at a time, so it can be called at any time.

.. versionadded:: 2.7


.. class:: FunctionTestCase(testFunc[, setUp[, tearDown[, description]]])

This class implements the portion of the :class:`TestCase` interface which
Expand Down Expand Up @@ -1046,6 +1075,20 @@ Grouping tests
Return the number of tests represented by this test object, including all
individual tests and sub-suites.


.. method:: __iter__()

Tests grouped by a :class:`TestSuite` are always accessed by iteration.
Subclasses can lazily provide tests by overriding :meth:`__iter__`. Note
that this method maybe called several times on a single suite
(for example when counting tests or comparing for equality)
so the tests returned must be the same for repeated iterations.

.. versionchanged:: 2.7
In earlier versions the :class:`TestSuite` accessed tests directly rather
than through iteration, so overriding :meth:`__iter__` wasn't sufficient
for providing tests.

In the typical usage of a :class:`TestSuite` object, the :meth:`run` method
is invoked by a :class:`TestRunner` rather than by the end-user test harness.

Expand Down Expand Up @@ -1190,7 +1233,6 @@ Loading and running tests
holding formatted tracebacks. Each tuple represents a test which raised an
unexpected exception.


.. attribute:: failures

A list containing 2-tuples of :class:`TestCase` instances and strings
Expand Down Expand Up @@ -1266,6 +1308,20 @@ Loading and running tests
The default implementation does nothing.


.. method:: startTestRun(test)

Called once before any tests are executed.

.. versionadded:: 2.7


.. method:: stopTestRun(test)

Called once before any tests are executed.

.. versionadded:: 2.7


.. method:: addError(test, err)

Called when the test case *test* raises an unexpected exception *err* is a
Expand Down Expand Up @@ -1335,8 +1391,14 @@ Loading and running tests
has a few configurable parameters, but is essentially very simple. Graphical
applications which run test suites should provide alternate implementations.

.. method:: _makeResult()

This method returns the instance of ``TestResult`` used by :meth:`run`.
It is not intended to be called directly, but can be overridden in
subclasses to provide a custom ``TestResult``.

.. function:: main([module[, defaultTest[, argv[, testRunner[, testLoader]]]]])

.. function:: main([module[, defaultTest[, argv[, testRunner[, testLoader[, exit]]]]]])

A command-line program that runs a set of tests; this is primarily for making
test modules conveniently executable. The simplest use for this function is to
Expand All @@ -1346,4 +1408,18 @@ Loading and running tests
unittest.main()

The *testRunner* argument can either be a test runner class or an already
created instance of it.
created instance of it. By default ``main`` calls :func:`sys.exit` with
an exit code indicating success or failure of the tests run.

``main`` supports being used from the interactive interpreter by passing in the
argument ``exit=False``. This displays the result on standard output without
calling :func:`sys.exit`::

>>> from unittest import main
>>> main(module='test_module', exit=False)

Calling ``main`` actually returns an instance of the ``TestProgram`` class.
This stores the result of the tests run as the ``result`` attribute.

.. versionchanged:: 2.7
The ``exit`` parameter was added.
Loading

0 comments on commit 25c95f1

Please sign in to comment.