test_simplelazyobject.py 502 B

1234567891011121314151617
  1. import pickle
  2. from django.contrib.auth.models import User
  3. from django.test import TestCase
  4. from django.utils.functional import SimpleLazyObject
  5. class TestUtilsSimpleLazyObjectDjangoTestCase(TestCase):
  6. def test_pickle(self):
  7. user = User.objects.create_user('johndoe', 'john@example.com', 'pass')
  8. x = SimpleLazyObject(lambda: user)
  9. pickle.dumps(x)
  10. # Try the variant protocol levels.
  11. pickle.dumps(x, 0)
  12. pickle.dumps(x, 1)
  13. pickle.dumps(x, 2)