From 36bbe3b7c52d459ed4862bbad1b44541a58cda00 Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Thu, 29 Aug 2013 14:50:55 -0400 Subject: [PATCH] Altered test introduced in f19a3669b8 for the sake of readability. refs #14786 --- tests/model_fields/tests.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/model_fields/tests.py b/tests/model_fields/tests.py index 0d327d6ae6..0ad0e168d7 100644 --- a/tests/model_fields/tests.py +++ b/tests/model_fields/tests.py @@ -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)