diff options
| author | Tim Graham <timograham@gmail.com> | 2013-09-18 09:35:51 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2013-09-18 09:42:47 -0400 |
| commit | 4f40b97d9728175c195c81f2413d800238bc8804 (patch) | |
| tree | 71552037f782681a8a49532d3e97b8dcd3457b2b /tests/utils_tests/test_simplelazyobject.py | |
| parent | 2f0566fa61e13277364e3aef338fa5c143f5a704 (diff) | |
Fixed #21118 -- Isolated a test that uses the database.
Thanks rmboggs for the report.
Diffstat (limited to 'tests/utils_tests/test_simplelazyobject.py')
| -rw-r--r-- | tests/utils_tests/test_simplelazyobject.py | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/tests/utils_tests/test_simplelazyobject.py b/tests/utils_tests/test_simplelazyobject.py index 8dd427e86a..6aac298dd1 100644 --- a/tests/utils_tests/test_simplelazyobject.py +++ b/tests/utils_tests/test_simplelazyobject.py @@ -5,6 +5,8 @@ import pickle import sys from unittest import TestCase +from django.contrib.auth.models import User +from django.test import TestCase as DjangoTestCase from django.utils import six from django.utils.functional import SimpleLazyObject, empty @@ -165,9 +167,19 @@ class TestUtilsSimpleLazyObject(TestCase): 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) @@ -186,13 +198,3 @@ class TestUtilsSimpleLazyObject(TestCase): # This would fail with "TypeError: expected string or Unicode object, NoneType found". pickled = cPickle.dumps(x) - - 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) |
