Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[1.6.x] Fixed #21118 -- Isolated a test that uses the database.

Thanks rmboggs for the report.

Backport of 4f40b97 from master
  • Loading branch information...
commit 14e139ecdfeec555265eec11d7bca7596311e348 1 parent 275497c
Tim Graham timgraham authored
Showing with 14 additions and 2 deletions.
  1. +14 −2 tests/utils_tests/test_simplelazyobject.py
16 tests/utils_tests/test_simplelazyobject.py
View
@@ -4,6 +4,8 @@
import pickle
import sys
+from django.contrib.auth.models import User
+from django.test import TestCase as DjangoTestCase
from django.utils import six
from django.utils.unittest import TestCase
from django.utils.functional import SimpleLazyObject, empty
@@ -162,9 +164,19 @@ def test_not_equal(self):
self.assertTrue(lazy1 != lazy3)
self.assertFalse(lazy1 != lazy2)
- def test_pickle_py2_regression(self):
- from django.contrib.auth.models import User
+ def test_list_set(self):
+ lazy_list = SimpleLazyObject(lambda: [1, 2, 3, 4, 5])
+ lazy_set = SimpleLazyObject(lambda: set([1, 2, 3, 4]))
+ self.assertTrue(1 in lazy_list)
+ self.assertTrue(1 in lazy_set)
+ self.assertFalse(6 in lazy_list)
+ self.assertFalse(6 in lazy_set)
+ self.assertEqual(len(lazy_list), 5)
+ self.assertEqual(len(lazy_set), 4)
+
+class TestUtilsSimpleLazyObjectDjangoTestCase(DjangoTestCase):
+ def test_pickle_py2_regression(self):
# See ticket #20212
user = User.objects.create_user('johndoe', 'john@example.com', 'pass')
x = SimpleLazyObject(lambda: user)
Please sign in to comment.
Something went wrong with that request. Please try again.