diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-01-11 20:13:03 +0200 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2017-01-11 20:13:03 +0200 |
commit | 3c70739866781670089dfd30215ddf62713181d9 (patch) | |
tree | 3427bd2a1b0cf82725c1526dfd7aedb264749e5a /Doc | |
parent | 7f5062be229f4724f23c3cc518582d754384a909 (diff) | |
download | cpython-3c70739866781670089dfd30215ddf62713181d9.tar.gz |
Issue #20804: The unittest.mock.sentinel attributes now preserve their
identity when they are copied or pickled.
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 ============= |