<div><div>Michael Foord <fuzzyman <at> <a href="http://voidspace.org.uk">voidspace.org.uk</a>> writes:</div><div>> On 2 Aug 2013, at 19:19, Antoine Pitrou <solipsis <at> <a href="http://pitrou.net">pitrou.net</a>> wrote:</div>
<div>> > The patch is basically ready for commit, except for a possible doc</div><div>> > addition, no?</div><div>> </div><div>> Looks to be the case, reading the patch it looks fine. I'm currently on holiday until Monday. </div>
<div>> If anyone is motivated to do the docs too and commit that would be great. Otherwise I'll</div><div>> get to it on my return.</div><div><br></div><div>It looks like the patch is based on what will become 3.4. Would backporting it to 2.7 be feasible?  What's involved in doing so?</div>
<div><br></div><div>I took a crack at the docs. </div><div><br></div><div># HG changeset patch</div><div># User Matt McClure <<a href="mailto:matthewlmcclure@gmail.com">matthewlmcclure@gmail.com</a>></div><div># Date 1375538965 14400</div>
<div># Node ID d748d70201929288c230862da4dbdba33d61ae9f</div><div># Parent  bf43956356ffe93e75ffdd5a7a8164fc68cf14ae</div><div>[11798] Document TestSuite.{__iter__, run} changes</div><div><br></div><div>diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst</div>
<div>--- a/Doc/library/unittest.rst</div><div>+++ b/Doc/library/unittest.rst</div><div>@@ -1470,15 +1470,24 @@</div><div> </div><div>       Tests grouped by a :class:`TestSuite` are always accessed by iteration.</div><div>
       Subclasses can lazily provide tests by overriding :meth:`__iter__`. Note</div><div>-      that this method maybe called several times on a single suite</div><div>-      (for example when counting tests or comparing for equality)</div>
<div>-      so the tests returned must be the same for repeated iterations.</div><div>+      that this method may be called several times on a single suite (for</div><div>+      example when counting tests or comparing for equality) so the tests</div>
<div>+      returned by repeated iterations before :meth:`TestSuite.run` must be the</div><div>+      same for each call iteration. After :meth:`TestSuite.run`, callers should</div><div>+      not rely on the tests returned by this method unless the caller uses a</div>
<div>+      subclass that overrides :meth:`TestSuite._removeTestAtIndex` to preserve</div><div>+      test references.</div><div> </div><div>       .. versionchanged:: 3.2</div><div>          In earlier versions the :class:`TestSuite` accessed tests directly rather</div>
<div>          than through iteration, so overriding :meth:`__iter__` wasn't sufficient</div><div>          for providing tests.</div><div> </div><div>+      .. versionchanged:: 3.4</div><div>+         In earlier versions the :class:`TestSuite` held references to each</div>
<div>+         :class:`TestCase` after :meth:`TestSuite.run`. Subclasses can restore</div><div>+         that behavior by overriding :meth:`TestSuite._removeTestAtIndex`.</div><div>+</div><div>    In the typical usage of a :class:`TestSuite` object, the :meth:`run` method</div>
<div>    is invoked by a :class:`TestRunner` rather than by the end-user test harness.</div><div> </div><div>diff --git a/Lib/unittest/suite.py b/Lib/unittest/suite.py</div><div>--- a/Lib/unittest/suite.py</div><div>+++ b/Lib/unittest/suite.py</div>
<div>@@ -65,6 +65,7 @@</div><div>         return result</div><div>         </div><div>     def _removeTestAtIndex(self, index):</div><div>+        """Stop holding a reference to the TestCase at index."""</div>
<div>         try:</div><div>             self._tests[index] = None</div><div>         except TypeError:</div><div><br></div><div>-- </div></div>Matt McClure<br><a href="http://matthewlmcclure.com" target="_blank">http://matthewlmcclure.com</a><br>
<a href="http://www.mapmyfitness.com/profile/matthewlmcclure" target="_blank">http://www.mapmyfitness.com/profile/matthewlmcclure</a><br>