Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #21118 -- Isolated a test that uses the database.

Thanks rmboggs for the report.
  • Loading branch information...
commit 4f40b97d9728175c195c81f2413d800238bc8804 1 parent 2f0566f
Tim Graham authored

Showing 1 changed file with 14 additions and 12 deletions. Show diff stats Hide diff stats

  1. 26  tests/utils_tests/test_simplelazyobject.py
26  tests/utils_tests/test_simplelazyobject.py
@@ -5,6 +5,8 @@
5 5
 import sys
6 6
 from unittest import TestCase
7 7
 
  8
+from django.contrib.auth.models import User
  9
+from django.test import TestCase as DjangoTestCase
8 10
 from django.utils import six
9 11
 from django.utils.functional import SimpleLazyObject, empty
10 12
 
@@ -165,9 +167,19 @@ def test_not_equal(self):
165 167
         self.assertTrue(lazy1 != lazy3)
166 168
         self.assertFalse(lazy1 != lazy2)
167 169
 
168  
-    def test_pickle_py2_regression(self):
169  
-        from django.contrib.auth.models import User
  170
+    def test_list_set(self):
  171
+        lazy_list = SimpleLazyObject(lambda: [1, 2, 3, 4, 5])
  172
+        lazy_set = SimpleLazyObject(lambda: set([1, 2, 3, 4]))
  173
+        self.assertTrue(1 in lazy_list)
  174
+        self.assertTrue(1 in lazy_set)
  175
+        self.assertFalse(6 in lazy_list)
  176
+        self.assertFalse(6 in lazy_set)
  177
+        self.assertEqual(len(lazy_list), 5)
  178
+        self.assertEqual(len(lazy_set), 4)
  179
+
  180
+class TestUtilsSimpleLazyObjectDjangoTestCase(DjangoTestCase):
170 181
 
  182
+    def test_pickle_py2_regression(self):
171 183
         # See ticket #20212
172 184
         user = User.objects.create_user('johndoe', 'john@example.com', 'pass')
173 185
         x = SimpleLazyObject(lambda: user)
@@ -186,13 +198,3 @@ def test_pickle_py2_regression(self):
186 198
 
187 199
             # This would fail with "TypeError: expected string or Unicode object, NoneType found".
188 200
             pickled = cPickle.dumps(x)
189  
-
190  
-    def test_list_set(self):
191  
-        lazy_list = SimpleLazyObject(lambda: [1, 2, 3, 4, 5])
192  
-        lazy_set = SimpleLazyObject(lambda: set([1, 2, 3, 4]))
193  
-        self.assertTrue(1 in lazy_list)
194  
-        self.assertTrue(1 in lazy_set)
195  
-        self.assertFalse(6 in lazy_list)
196  
-        self.assertFalse(6 in lazy_set)
197  
-        self.assertEqual(len(lazy_list), 5)
198  
-        self.assertEqual(len(lazy_set), 4)

0 notes on commit 4f40b97

Please sign in to comment.
Something went wrong with that request. Please try again.