[Python-checkins] cpython: whatsnew: unittest drops references to successful tests.

r.david.murray python-checkins at python.org
Mon Feb 24 03:38:12 CET 2014


http://hg.python.org/cpython/rev/1063e7b57a88
changeset:   89348:1063e7b57a88
parent:      89346:73aa6d672b81
user:        R David Murray <rdmurray at bitdance.com>
date:        Sun Feb 23 20:53:50 2014 -0500
summary:
  whatsnew: unittest drops references to successful tests.

files:
  Doc/whatsnew/3.4.rst |  18 ++++++++++++++++++
  1 files changed, 18 insertions(+), 0 deletions(-)


diff --git a/Doc/whatsnew/3.4.rst b/Doc/whatsnew/3.4.rst
--- a/Doc/whatsnew/3.4.rst
+++ b/Doc/whatsnew/3.4.rst
@@ -1286,6 +1286,14 @@
 consistent test ordering.  (Contributed by Martin Melin and Jeff Ramnani in
 :issue:`16709`.)
 
+:class:`~unittest.TestSuite` now drops references to tests as soon as the test
+has been run, if the test is successful.  On Python interpreters that do
+garbage collection, this allows the tests to be garbage collected if nothing
+else is holding a reference to the test.  It is possible to override this
+behavior by creating a :class:`~unittest.TestSuite` subclass that defines a
+custom ``_removeTestAtIndex`` method.  (Contributed by Tom Wardill, Matt
+McClure, and Andrew Svetlov in :issue:`11798`.)
+
 
 venv
 ----
@@ -1871,6 +1879,16 @@
   Previously some builtin hashes had uppercase names, but now that it is a
   formal public interface the naming has been made consistent (:issue:`18532`).
 
+* Because :mod:`unittest.TestSuite` now drops references to tests after they
+  are run, test harnesses that re-use a :class:`~unittest.TestSuite` to re-run
+  a set of tests may fail.   Test suites should not be re-used in this fashion
+  since it means state is retained between test runs, breaking the test
+  isolation that :mod:`unittest` is designed to provide.  However, if the lack
+  of isolation is considered acceptable, the old behavior can be restored by
+  creating a :mod:`~unittest.TestSuite` subclass that defines a
+  ``_removeTestAtIndex`` method that does nothing (see
+  :meth:`.TestSuite.__iter__`) (:issue:`11798`).
+
 
 Changes in the C API
 --------------------

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list