Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ef3da23

Browse files
committed
whatsnew: unittest drops references to successful tests.
1 parent 9e2b14c commit ef3da23

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

Doc/whatsnew/3.4.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,14 @@ error. (Contributed by Zach Ware in :issue:`16935`.)
12861286
consistent 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

12901298
venv
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

18751893
Changes in the C API
18761894
--------------------

0 commit comments

Comments
 (0)