classification
Title: Can't pickle unittest.TestCase instances
Type: behavior Stage: needs patch
Components: Library (Lib) Versions: Python 3.2, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: michael.foord Nosy List: MarkRoddy, michael.foord, python-dev
Priority: low Keywords: easy, patch

Created on 2010-11-05 14:17 by michael.foord, last changed 2011-06-25 10:18 by rhettinger. This issue is now closed.

Files
File name Uploaded Description Edit
python27.pickle.patch MarkRoddy, 2010-11-06 03:21 review
python3k.pickle.patch MarkRoddy, 2010-11-06 03:22 review
Messages (5)
msg120496 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2010-11-05 14:17
In Python 2.7 a change was introduced to TestCase which involves storing a dictionary of method objects on TestCase instances. This makes them unpickleable.

unittest2 stores strings (method names) instead of method objects (a fix to make TestCase instances copyable under earlier versions of Python). The same fix could be applied to unittest.
msg120575 - (view) Author: Mark Roddy (MarkRoddy) * Date: 2010-11-06 03:21
Patch which makes TestCase pickle-able for Python 2.7, includes unit test
msg120576 - (view) Author: Mark Roddy (MarkRoddy) * Date: 2010-11-06 03:22
Attaching patch which makes TestCase pickle-able for Python 3.2, includes unit test
msg121666 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2010-11-20 15:35
Applied to Python 3.2 in revision 86570.

Python 2.7 will have to be fixed after the next release as we are currently in release candidate stage.
msg139041 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-06-25 10:16
New changeset 9c337a4c650d by Raymond Hettinger in branch '2.7':
Issue 10326: Fix regression to get test cases to pickle again.
http://hg.python.org/cpython/rev/9c337a4c650d
History
Date User Action Args
2011-06-25 10:18:10rhettingersetstatus: open -> closed
resolution: fixed
2011-06-25 10:16:35python-devsetnosy: + python-dev
messages: + msg139041
2010-11-20 15:35:08michael.foordsetmessages: + msg121666
2010-11-06 03:22:52MarkRoddysetfiles: + python3k.pickle.patch

messages: + msg120576
2010-11-06 03:21:57MarkRoddysetfiles: + python27.pickle.patch

nosy: + MarkRoddy
messages: + msg120575

keywords: + patch
2010-11-05 14:17:27michael.foordcreate