Only the parts which are relevant for 3.x branch.

Merged revisions 78757-78758,78769,78815 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r78757 | florent.xicluna | 2010-03-07 13:14:25 +0100 (dim, 07 mar 2010) | 2 lines

  Fix some py3k warnings in the standard library.
........
  r78758 | florent.xicluna | 2010-03-07 13:18:33 +0100 (dim, 07 mar 2010) | 4 lines

  Issue #7849: Now the utility ``check_warnings`` verifies if the warnings are
  effectively raised.  A new utility ``check_py3k_warnings`` deals with py3k warnings.
........
  r78769 | florent.xicluna | 2010-03-07 20:14:12 +0100 (dim, 07 mar 2010) | 2 lines

  Refresh the documentation for the test.test_support module.
........
  r78815 | florent.xicluna | 2010-03-09 20:57:01 +0100 (mar, 09 mar 2010) | 2 lines

  #7772: Fix test_py3kwarn. Now the test suite could pass with "-3" flag.
........
diff --git a/Doc/library/test.rst b/Doc/library/test.rst
index cc7ff4d..d8dd46c 100644
--- a/Doc/library/test.rst
+++ b/Doc/library/test.rst
@@ -130,13 +130,13 @@
              self.func(self.arg)
 
      class AcceptLists(TestFuncAcceptsSequences):
-         arg = [1,2,3]
+         arg = [1, 2, 3]
 
      class AcceptStrings(TestFuncAcceptsSequences):
          arg = 'abc'
 
      class AcceptTuples(TestFuncAcceptsSequences):
-         arg = (1,2,3)
+         arg = (1, 2, 3)
 
 
 .. seealso::
@@ -198,16 +198,9 @@
    methods.
 
 
-.. exception:: TestSkipped
-
-   Subclass of :exc:`TestFailed`. Raised when a test is skipped. This occurs when a
-   needed resource (such as a network connection) is not available at the time of
-   testing.
-
-
 .. exception:: ResourceDenied
 
-   Subclass of :exc:`TestSkipped`. Raised when a resource (such as a network
+   Subclass of :exc:`unittest.SkipTest`. Raised when a resource (such as a network
    connection) is not available. Raised by the :func:`requires` function.
 
 The :mod:`test.support` module defines the following constants:
@@ -227,7 +220,7 @@
 
 .. data:: TESTFN
 
-   Set to the path that a temporary file may be created at. Any temporary that is
+   Set to the name that a temporary file could use. Any temporary file that is
    created should be closed and unlinked (removed).
 
 The :mod:`test.support` module defines the following functions:
@@ -235,21 +228,21 @@
 
 .. function:: forget(module_name)
 
-   Removes the module named *module_name* from ``sys.modules`` and deletes any
+   Remove the module named *module_name* from ``sys.modules`` and deletes any
    byte-compiled files of the module.
 
 
 .. function:: is_resource_enabled(resource)
 
-   Returns :const:`True` if *resource* is enabled and available. The list of
+   Return :const:`True` if *resource* is enabled and available. The list of
    available resources is only set when :mod:`test.regrtest` is executing the
    tests.
 
 
 .. function:: requires(resource, msg=None)
 
-   Raises :exc:`ResourceDenied` if *resource* is not available. *msg* is the
-   argument to :exc:`ResourceDenied` if it is raised. Always returns true if called
+   Raise :exc:`ResourceDenied` if *resource* is not available. *msg* is the
+   argument to :exc:`ResourceDenied` if it is raised. Always returns True if called
    by a function whose ``__name__`` is ``'__main__'``. Used when tests are executed
    by :mod:`test.regrtest`.
 
@@ -277,14 +270,24 @@
    This will run all tests defined in the named module.
 
 
-.. function:: check_warnings()
+.. function:: check_warnings(*filters, quiet=False)
 
    A convenience wrapper for ``warnings.catch_warnings()`` that makes
    it easier to test that a warning was correctly raised with a single
    assertion. It is approximately equivalent to calling
    ``warnings.catch_warnings(record=True)``.
 
-   The main difference is that on entry to the context manager, a
+   It accepts 2-tuples ``("message regexp", WarningCategory)`` as positional
+   arguments. When the optional keyword argument ``quiet`` is True, it does
+   not fail if a filter catches nothing. Without argument, it defaults to::
+
+      check_warnings(("", Warning), quiet=False)
+
+   The main difference is that it verifies the warnings raised. If some filter
+   did not catch any warning, the test fails. If some warnings are not caught,
+   the test fails, too. To disable these checks, use argument ``quiet=True``.
+
+   Another significant difference is that on entry to the context manager, a
    :class:`WarningRecorder` instance is returned instead of a simple list.
    The underlying warnings list is available via the recorder object's
    :attr:`warnings` attribute, while the attributes of the last raised
@@ -294,19 +297,34 @@
    A :meth:`reset` method is also provided on the recorder object. This
    method simply clears the warning list.
 
-   The context manager is used like this::
+   The context manager may be used like this::
 
-      with check_warnings() as w:
+      import warnings
+
+      with check_warnings():
+          exec('assert(False, "Hey!")')
+          warnings.warn(UserWarning("Hide me!"))
+
+      with check_warnings(("assertion is always true", SyntaxWarning),
+                          ("", UserWarning)):
+          exec('assert(False, "Hey!")')
+          warnings.warn(UserWarning("Hide me!"))
+
+      with check_warnings(quiet=True) as w:
           warnings.simplefilter("always")
           warnings.warn("foo")
-          assert str(w.message) == "foo"
+          assert str(w.args[0]) == "foo"
           warnings.warn("bar")
-          assert str(w.message) == "bar"
-          assert str(w.warnings[0].message) == "foo"
-          assert str(w.warnings[1].message) == "bar"
+          assert str(w.args[0]) == "bar"
+          assert str(w.warnings[0].args[0]) == "foo"
+          assert str(w.warnings[1].args[0]) == "bar"
           w.reset()
           assert len(w.warnings) == 0
 
+   .. versionchanged:: 2.7
+      The test fails when the context manager do not catch any warning.
+      New optional attributes ``*filters`` and ``quiet``.
+
 
 .. function:: captured_stdout()