Kaydet (Commit) 36bbe3b7 authored tarafından Simon Charette's avatar Simon Charette

Altered test introduced in f19a3669 for the sake of readability. refs #14786

üst 50d25a9c
......@@ -672,12 +672,17 @@ class CustomFieldTests(unittest.TestCase):
Regression test for #14786 -- Test that field values are not prepared
twice in get_db_prep_lookup().
"""
prepare_count = [0]
class NoopField(models.TextField):
def __init__(self, *args, **kwargs):
self.prep_value_count = 0
super(NoopField, self).__init__(*args, **kwargs)
def get_prep_value(self, value):
prepare_count[0] += 1
self.prep_value_count += 1
return super(NoopField, self).get_prep_value(value)
field = NoopField()
field.get_db_prep_lookup('exact', 'TEST', connection=connection, prepared=False)
self.assertEqual(prepare_count[0], 1)
field.get_db_prep_lookup(
'exact', 'TEST', connection=connection, prepared=False
)
self.assertEqual(field.prep_value_count, 1)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment