Commit dc2f9b5c authored by Raymond Hettinger's avatar Raymond Hettinger

Update the unittest section.

parent 7d819751
...@@ -651,23 +651,33 @@ New, Improved, and Deprecated Modules ...@@ -651,23 +651,33 @@ New, Improved, and Deprecated Modules
as recommended in public uses of HTTPS. as recommended in public uses of HTTPS.
(Added by Antoine Pitrou, :issue:`9003`.) (Added by Antoine Pitrou, :issue:`9003`.)
* Instances of :class:`unittest.TestCase` have two new methods * The command call, ``python -m unittest`` can now accept file paths instead
:meth:`~unittest.TestCase.assertWarns` and :meth:`~unittest.TestCase.assertWarnsRegexp` of module names for running specific tests (:issue:`10620`).
to check that a given warning type was triggered by the code under test::
* The :mod:`unittest` module has two new methods,
with self.assertWarns(DeprecationWarning): :meth:`~unittest.TestCase.assertWarns` and
legacy_function('XYZ') :meth:`~unittest.TestCase.assertWarnsRegex` to check that a given warning type
was triggered by the code under test:
* The following :class:`unittest.TestCase` methods are now deprecated:
* :meth:`assert_` (use :meth:`.assertTrue` instead); >>> with self.assertWarns(DeprecationWarning):
* :meth:`assertEquals` (use :meth:`.assertEqual` instead); ... legacy_function('XYZ')
* :meth:`assertNotEquals` (use :meth:`.assertNotEqual` instead);
* :meth:`assertAlmostEquals` (use :meth:`.assertAlmostEqual` instead); In addition, the naming in the module has ungone a number of clean-ups.
* :meth:`assertNotAlmostEquals` (use :meth:`.assertNotAlmostEqual` instead); For example, :meth:`assertRegex` is the new name for :meth:`assertRegexpMatches`
which was misnamed because the test uses :func:`re.search`, not :func:`re.match`.
The ``TestCase.fail*`` methods deprecated in Python 3.1 will be removed in
Python 3.3. See also the :ref:`deprecated-aliases` section in the To improve consistency, some of long-standing method aliases are being
:mod:`unittest` documentation. deprecated in favor of the preferred names:
- replace :meth:`assert_` with :meth:`.assertTrue`
- replace :meth:`assertEquals` with :meth:`.assertEqual`
- replace :meth:`assertNotEquals` with :meth:`.assertNotEqual`
- replace :meth:`assertAlmostEquals` with :meth:`.assertAlmostEqual`
- replace :meth:`assertNotAlmostEquals` with :meth:`.assertNotAlmostEqual`
Likewise, the ``TestCase.fail*`` methods deprecated in Python 3.1 are expected
to be removed in Python 3.3. See also the :ref:`deprecated-aliases` section in
the :mod:`unittest` documentation.
(Contributed by Ezio Melotti; :issue:`9424`.) (Contributed by Ezio Melotti; :issue:`9424`.)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment