From 3c70739866781670089dfd30215ddf62713181d9 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Wed, 11 Jan 2017 20:13:03 +0200 Subject: Issue #20804: The unittest.mock.sentinel attributes now preserve their identity when they are copied or pickled. --- Doc/library/unittest.mock.rst | 4 ++++ Doc/whatsnew/3.7.rst | 7 +++++++ 2 files changed, 11 insertions(+) (limited to 'Doc') 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 ` or :mod:`pickled `. + 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 ` or :mod:`pickled `. +(Contributed by Serhiy Storchaka in :issue:`20804`.) + Optimizations ============= -- cgit v1.2.1