Opened 5 years ago

Closed 5 years ago

#31173 closed Bug (invalid)

Testing with PickleSerializer and Mock objects breaks.

Reported by: Mmadu Manasseh Owned by: nobody
Component: contrib.sessions Version: 3.0
Severity: Normal Keywords: Pickle, Mock, Session
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When trying to mock a session object when the session serializer is set to Pickle throws an error.
_pickle.PicklingError: Can't pickle <class 'mock.mock.Mock'>: it's not the same object as mock.mock.Mock

This is an inherent problem in python which can be found in issue: https://bugs.python.org/issue20804 and https://github.com/testing-cabal/mock/issues/139.

I think Django should provide a way to make the PickleSerializer overcome this issue.

Change History (1)

comment:1 by Mariusz Felisiak, 5 years ago

Component: Testing frameworkcontrib.sessions
Resolution: invalid
Status: newclosed
Summary: Testing with PickleSerializer and Mock objects breaksTesting with PickleSerializer and Mock objects breaks.

This is a known limitation of pickle, and I don't see how we could handle this in Django. You can always use a custom Mock subclass, which will work with pickle.

Note: See TracTickets for help on using tickets.
Back to Top