1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #11629 -- Deprecated callable arguments to queryset methods.

Callable arguments were an untested and undocumented feature.
This commit is contained in:
Baptiste Mispelon
2013-12-18 16:59:08 +01:00
parent d34c8c338a
commit f1b3ab9c21
4 changed files with 29 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ import datetime
from operator import attrgetter
import pickle
import unittest
import warnings
from django.core.exceptions import FieldError
from django.db import DatabaseError, connection, connections, DEFAULT_DB_ALIAS
@@ -1139,6 +1140,17 @@ class Queries1Tests(BaseQuerysetTest):
['<Author: a1>', '<Author: a2>', '<Author: a3>', '<Author: a4>']
)
def test_callable_args(self):
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
qs = Tag.objects.filter(name__startswith=lambda: 't')
self.assertQuerysetEqual(
qs,
['<Tag: t1>', '<Tag: t2>', '<Tag: t3>', '<Tag: t4>', '<Tag: t5>']
)
self.assertEqual(len(w), 1)
self.assertTrue(issubclass(w[0].category, PendingDeprecationWarning))
class Queries2Tests(TestCase):
def setUp(self):