[Python-Dev] r86570 - in python/branches/py3k: Lib/unittest/case.py Lib/unittest/test/test_case.py Misc/NEWS (original) (raw)
Michael Foord fuzzyman at voidspace.org.uk
Sat Nov 20 16:48:59 CET 2010
- Previous message: [Python-Dev] r86570 - in python/branches/py3k: Lib/unittest/case.py Lib/unittest/test/test_case.py Misc/NEWS
- Next message: [Python-Dev] r86570 - in python/branches/py3k: Lib/unittest/case.py Lib/unittest/test/test_case.py Misc/NEWS
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 20/11/2010 15:42, Antoine Pitrou wrote:
On Sat, 20 Nov 2010 16:34:26 +0100 (CET) michael.foord<python-checkins at python.org> wrote:
+ + def testPickle(self): + # Issue 10326 + + # Can't use TestCase classes defined in Test class as + # pickle does not work with inner classes + test = unittest.TestCase('run') + for protocol in range(pickle.HIGHESTPROTOCOL + 1): + + # blew up prior to fix + pickledtest = pickle.dumps(test, protocol=protocol) You must also check that the object can be unpickled, otherwise making TestCase picklable is not only pointless, but misleading the user. Other classes which claim to be picklable (such as e.g. io.BytesIO) are careful to check that unpickling works fine and produces an usable object.
Well, given the particular bug it is fixing, ensuring that the TestCase instances can be pickled is enough. If they fail to unpickle that is a bug in pickle and not in unittest. However, the test is very easy to extend to what you suggest so I have done it.
All the best,
Michael
Regards
Antoine.
Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/fuzzyman%40voidspace.org.uk
--
READ CAREFULLY. By accepting and reading this email you agree, on behalf of your employer, to release me from all obligations and waivers arising from any and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap, clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and acceptable use policies (”BOGUS AGREEMENTS”) that I have entered into with your employer, its partners, licensors, agents and assigns, in perpetuity, without prejudice to my ongoing rights and privileges. You further represent that you have the authority to release me from any BOGUS AGREEMENTS on behalf of your employer.
- Previous message: [Python-Dev] r86570 - in python/branches/py3k: Lib/unittest/case.py Lib/unittest/test/test_case.py Misc/NEWS
- Next message: [Python-Dev] r86570 - in python/branches/py3k: Lib/unittest/case.py Lib/unittest/test/test_case.py Misc/NEWS
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]