Issue #20804: The unittest.mock.sentinel attributes now preserve their

identity when they are copied or pickled.
This commit is contained in:
Serhiy Storchaka 2017-01-11 20:13:03 +02:00
parent d4f5001bac
commit d9c956fb23
5 changed files with 33 additions and 0 deletions

View file

@ -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()