Opened 6 years ago
Closed 6 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 , 6 years ago
| Component: | Testing framework → contrib.sessions |
|---|---|
| Resolution: | → invalid |
| Status: | new → closed |
| Summary: | Testing with PickleSerializer and Mock objects breaks → Testing 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 withpickle.