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