diff options
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/unittest.mock.rst | 4 | ||||
-rw-r--r-- | Doc/whatsnew/3.7.rst | 7 |
2 files changed, 11 insertions, 0 deletions
diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst index 3cc22fdde7..ca5c2bc787 100644 --- a/Doc/library/unittest.mock.rst +++ b/Doc/library/unittest.mock.rst @@ -1831,6 +1831,10 @@ sentinel the same attribute will always return the same object. The objects returned have a sensible repr so that test failure messages are readable. + .. versionchanged:: 3.7 + The ``sentinel`` attributes now preserve their identity when they are + :mod:`copied <copy>` or :mod:`pickled <pickle>`. + Sometimes when testing you need to test that a specific object is passed as an argument to another method, or returned. It can be common to create named sentinel objects to test this. :data:`sentinel` provides a convenient way of diff --git a/Doc/whatsnew/3.7.rst b/Doc/whatsnew/3.7.rst index 0d19f25942..a2e6422793 100644 --- a/Doc/whatsnew/3.7.rst +++ b/Doc/whatsnew/3.7.rst @@ -93,6 +93,13 @@ New Modules Improved Modules ================ +unittest.mock +------------- + +The :const:`~unittest.mock.sentinel` attributes now preserve their identity +when they are :mod:`copied <copy>` or :mod:`pickled <pickle>`. +(Contributed by Serhiy Storchaka in :issue:`20804`.) + Optimizations ============= |