From d9c956fb23f1c38c8050e9531ff5a77559f7f7af 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. --- Lib/unittest/mock.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Lib/unittest/mock.py') diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py index dbb05d780ea..2ec14e555ae 100644 --- a/Lib/unittest/mock.py +++ b/Lib/unittest/mock.py @@ -238,6 +238,9 @@ class _SentinelObject(object): def __repr__(self): return 'sentinel.%s' % self.name + def __reduce__(self): + return 'sentinel.%s' % self.name + class _Sentinel(object): """Access attributes to return a named object, usable as a sentinel.""" @@ -250,6 +253,9 @@ class _Sentinel(object): raise AttributeError return self._sentinels.setdefault(name, _SentinelObject(name)) + def __reduce__(self): + return 'sentinel' + sentinel = _Sentinel() -- cgit v1.2.3