summaryrefslogtreecommitdiffstats
path: root/Doc/whatsnew
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2014-01-04 04:31:54 (GMT)
committerR David Murray <rdmurray@bitdance.com>2014-01-04 04:31:54 (GMT)
commit57fcf76d73441bd766e3644875472e6b19791e02 (patch)
tree6435a11962676fa7fbf36cb83e47d2399d8b5039 /Doc/whatsnew
parent37148b27ac742bc61087a8413863d70d43476bf4 (diff)
downloadcpython-57fcf76d73441bd766e3644875472e6b19791e02.zip
cpython-57fcf76d73441bd766e3644875472e6b19791e02.tar.gz
cpython-57fcf76d73441bd766e3644875472e6b19791e02.tar.bz2
whatsnew: Mock mock_open readline(s); expand description of subtests feature.
Diffstat (limited to 'Doc/whatsnew')
-rw-r--r--Doc/whatsnew/3.4.rst28
1 files changed, 23 insertions, 5 deletions
diff --git a/Doc/whatsnew/3.4.rst b/Doc/whatsnew/3.4.rst
index dbebf46..40aa787 100644
--- a/Doc/whatsnew/3.4.rst
+++ b/Doc/whatsnew/3.4.rst
@@ -759,6 +759,9 @@ matching calls, which means an argument can now be matched by either position
or name, instead of only by position. (Contributed by Antoine Pitrou in
:issue:`17015`.)
+:func:`~mock.mock_open` objects now have ``readline`` and ``readlines``
+methods. (Contributed by Toshio Kuratomi in :issue:`17467`.)
+
multiprocessing
---------------
@@ -1010,11 +1013,26 @@ in :issue:`16423`.)
unittest
--------
-Support for easy dynamically-generated subtests using the
-:meth:`~unittest.TestCase.subTest` context manager.
-(Contributed by Antoine Pitrou in :issue:`16997`.)
-
-:func:`unittest.main` now also accepts an iterable of test names for
+The :class:`~unittest.TestCase` class has a new method,
+:meth:`~unittest.TestCase.subTest`, that produces a context manager whose
+:keyword:`with` block becomes a "sub-test". This context manager allows a test
+method to dynamically generate subtests by, say, calling the ``subTest``
+context manager inside a loop. A single test method can thereby produce an
+indefinite number of separately-identified and separately-counted tests, all of
+which will run even if one or more of them fail. For example::
+
+ class NumbersTest(unittest.TestCase):
+ def test_even(self):
+ for i in range(6):
+ with self.subTest(i=1):
+ self.assertEqual(i % 2, 0)
+
+will result in six subtests, each identified in the unittest verbose output
+with a label consisting of the variable name ``i`` and a particular value for
+that variable (``i=0``, ``i=1``, etc). See :ref:`subtests` for the full
+version of this example. (Contributed by Antoine Pitrou in :issue:`16997`.)
+
+:func:`unittest.main` now accepts an iterable of test names for
*defaultTest*, where previously it only accepted a single test name as a
string. (Contributed by Jyrki Pulliainen in :issue:`15132`.)