From 16fe73d918c8a35f7122aed858312bd3163ac454 Mon Sep 17 00:00:00 2001 From: Joseph Kocherhans Date: Wed, 24 Feb 2010 17:36:18 +0000 Subject: Fixed #7190. Boolean fields now return bool values instead of 1 or 0. Thanks, Alex Gaynor. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12578 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/regressiontests/model_fields/tests.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests') diff --git a/tests/regressiontests/model_fields/tests.py b/tests/regressiontests/model_fields/tests.py index 18bfbd37ee..2ac0af3267 100644 --- a/tests/regressiontests/model_fields/tests.py +++ b/tests/regressiontests/model_fields/tests.py @@ -108,12 +108,22 @@ class BooleanFieldTests(unittest.TestCase): self.assertEqual(f.get_db_prep_lookup('exact', 0, connection=connection), [False]) self.assertEqual(f.get_db_prep_lookup('exact', None, connection=connection), [None]) + def _test_to_python(self, f): + self.assertTrue(f.to_python(1) is True) + self.assertTrue(f.to_python(0) is False) + def test_booleanfield_get_db_prep_lookup(self): self._test_get_db_prep_lookup(models.BooleanField()) def test_nullbooleanfield_get_db_prep_lookup(self): self._test_get_db_prep_lookup(models.NullBooleanField()) + def test_booleanfield_to_python(self): + self._test_to_python(models.BooleanField()) + + def test_nullbooleanfield_to_python(self): + self._test_to_python(models.NullBooleanField()) + def test_booleanfield_choices_blank(self): """ Test that BooleanField with choices and defaults doesn't generate a -- cgit v1.3