New submission from Vlastimil Zíma:

Sentinels lose their identity when they are pickled, meaning they are no longer 
equal to sentinel with the same name.


>>> from mock import sentinel
>>> import pickle
>>> sentinel.foo == sentinel.foo
True
>>> pickle.loads(pickle.dumps(sentinel.foo)) == sentinel.foo
False


I found this bug using Python 2.7.3 and python-mock 1.0.1. Since mock 1.0 is 
part of Python 3.3 and 3.4 it affects these versions (tested in 3.3.3).

This behavior is tricky to find out if encountered in tests and sentinels can 
not be used in tests of code which uses pickle and possibly other 
serializations.

----------
components: Tests
messages: 212417
nosy: Vlastimil.Zíma
priority: normal
severity: normal
status: open
title: Sentinels identity lost when pickled (unittest.mock)
type: behavior
versions: Python 3.3, Python 3.4

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue20804>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to