2011-12-15 02:33:14 +00:00
|
|
|
import pickle
|
2010-09-27 15:15:04 +00:00
|
|
|
|
2013-09-18 13:35:51 +00:00
|
|
|
from django.contrib.auth.models import User
|
2014-01-29 04:53:30 +00:00
|
|
|
from django.test import TestCase
|
|
|
|
from django.utils.functional import SimpleLazyObject
|
2011-06-01 15:30:06 +00:00
|
|
|
|
2010-09-27 15:15:04 +00:00
|
|
|
|
2014-01-29 04:53:30 +00:00
|
|
|
class TestUtilsSimpleLazyObjectDjangoTestCase(TestCase):
|
2013-05-21 05:17:56 +00:00
|
|
|
|
2017-01-22 01:02:00 +00:00
|
|
|
def test_pickle(self):
|
2013-05-21 05:17:56 +00:00
|
|
|
user = User.objects.create_user('johndoe', 'john@example.com', 'pass')
|
|
|
|
x = SimpleLazyObject(lambda: user)
|
2013-10-19 12:31:38 +00:00
|
|
|
pickle.dumps(x)
|
2013-05-21 05:17:56 +00:00
|
|
|
# Try the variant protocol levels.
|
2013-10-19 12:31:38 +00:00
|
|
|
pickle.dumps(x, 0)
|
|
|
|
pickle.dumps(x, 1)
|
|
|
|
pickle.dumps(x, 2)
|