示例#1
0
    def test_nullify_invalid_true(self):
        val = Decimal('1.5')
        o = DecimalCharFieldModel()
        o.loose = val
        eq_(o.loose, val, 'unexpected Decimal value')

        o.loose = 'not a decimal'
        eq_(o.loose, None, 'expected None')
示例#2
0
    def test_nullify_invalid_true(self):
        val = Decimal("1.5")
        o = DecimalCharFieldModel()
        o.loose = val
        eq_(o.loose, val, "unexpected Decimal value")

        o.loose = "not a decimal"
        eq_(o.loose, None, "expected None")
示例#3
0
 def test_nullify_invalid_false(self):
     val = Decimal('1.5')
     o = DecimalCharFieldModel()
     o.strict = val
     try:
         o.strict = 'not a decimal'
     except exceptions.ValidationError:
         pass
     else:
         assert False, 'invalid value did not raise an exception'
     eq_(o.strict, val, 'unexpected Decimal value')
示例#4
0
 def test_nullify_invalid_false(self):
     val = Decimal("1.5")
     o = DecimalCharFieldModel()
     o.strict = val
     try:
         o.strict = "not a decimal"
     except exceptions.ValidationError:
         pass
     else:
         assert False, "invalid value did not raise an exception"
     eq_(o.strict, val, "unexpected Decimal value")
示例#5
0
    def test_save(self):
        a = DecimalCharFieldModel()
        a.strict = '1.23'
        a.loose = 'this had better be NULL'
        a.save()

        b = DecimalCharFieldModel.objects.get(pk=a.id)
        eq_(b.strict, Decimal('1.23'))
        eq_(b.loose, None)