예제 #1
0
 def test_is_valid(self):
     field = BooleanField('', required=False)
     field.value = True
     self.assertTrue(field.is_valid)
     field.value = "yes"
     self.assertTrue(field.is_valid)
     field.value = 0
     self.assertTrue(field.is_valid)
     field.value = False
     self.assertTrue(field.is_valid)
예제 #2
0
 def test_cleaned_data_false(self):
     field = BooleanField('', required=False)
     for value in [0, False, 'no', 'false', 'FALSE', 'False', '0', 'null']:
         field.value = value
         self.assertIsNone(
             field.cleaned_value,
             "invalid value for %r" % (value,)
         )
예제 #3
0
 def test_cleaned_data_true(self):
     field = BooleanField('', required=False)
     for value in [1, True, 'yes', 'true', 'TRUE', 'True', 'LOL', '1',
                   object(), type('', (), {})]:
         field.value = value
         self.assertTrue(
             field.cleaned_value,
             "invalid value for %s" % value
         )
예제 #4
0
 def test_cleaned_data_none(self):
     field = BooleanField('', required=False)
     field.value = None
     self.assertIsNone(field.cleaned_value)