@@ -1286,6 +1286,14 @@ error. (Contributed by Zach Ware in :issue:`16935`.)
12861286consistent test ordering. (Contributed by Martin Melin and Jeff Ramnani in
12871287:issue: `16709 `.)
12881288
1289+ :class: `~unittest.TestSuite ` now drops references to tests as soon as the test
1290+ has been run, if the test is successful. On Python interpreters that do
1291+ garbage collection, this allows the tests to be garbage collected if nothing
1292+ else is holding a reference to the test. It is possible to override this
1293+ behavior by creating a :class: `~unittest.TestSuite ` subclass that defines a
1294+ custom ``_removeTestAtIndex `` method. (Contributed by Tom Wardill, Matt
1295+ McClure, and Andrew Svetlov in :issue: `11798 `.)
1296+
12891297
12901298venv
12911299----
@@ -1871,6 +1879,16 @@ Changes in the Python API
18711879 Previously some builtin hashes had uppercase names, but now that it is a
18721880 formal public interface the naming has been made consistent (:issue: `18532 `).
18731881
1882+ * Because :mod: `unittest.TestSuite ` now drops references to tests after they
1883+ are run, test harnesses that re-use a :class: `~unittest.TestSuite ` to re-run
1884+ a set of tests may fail. Test suites should not be re-used in this fashion
1885+ since it means state is retained between test runs, breaking the test
1886+ isolation that :mod: `unittest ` is designed to provide. However, if the lack
1887+ of isolation is considered acceptable, the old behavior can be restored by
1888+ creating a :mod: `~unittest.TestSuite ` subclass that defines a
1889+ ``_removeTestAtIndex `` method that does nothing (see
1890+ :meth: `.TestSuite.__iter__ `) (:issue: `11798 `).
1891+
18741892
18751893Changes in the C API
18761894--------------------
0 commit comments