diff options
| author | Shai Berger <shai@platonix.com> | 2014-03-12 20:17:43 +0200 |
|---|---|---|
| committer | Shai Berger <shai@platonix.com> | 2014-03-12 20:17:43 +0200 |
| commit | d181384e5f01e9d23fd9872b2cb532e0d70249b6 (patch) | |
| tree | e849f1312ea7d84ff5e0bd645340c7591da662f0 | |
| parent | aaad3e27ac7cfcbbfeac6353d17d27e8da523cc8 (diff) | |
Fixed test failure on Oracle: model_fields.tests.test_float_validates_object
Failing test introduced in fix for refs #22210.
| -rw-r--r-- | tests/model_fields/tests.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/tests/model_fields/tests.py b/tests/model_fields/tests.py index a39ad81f64..8cd58b8a44 100644 --- a/tests/model_fields/tests.py +++ b/tests/model_fields/tests.py @@ -8,7 +8,7 @@ import warnings from django import test from django import forms from django.core.exceptions import ValidationError -from django.db import connection, models, IntegrityError +from django.db import connection, transaction, models, IntegrityError from django.db.models.fields import ( AutoField, BigIntegerField, BinaryField, BooleanField, CharField, CommaSeparatedIntegerField, DateField, DateTimeField, DecimalField, @@ -80,10 +80,22 @@ class BasicFieldTests(test.TestCase): def test_float_validates_object(self): instance = FloatModel(size=2.5) + # Try setting float field to unsaved object + instance.size = instance + with transaction.atomic(): + with self.assertRaises(TypeError): + instance.save() + # Set value to valid and save + instance.size = 2.5 instance.save() self.assertTrue(instance.id) - - obj = FloatModel.objects.get(pk=1) + # Set field to object on saved instance + instance.size = instance + with transaction.atomic(): + with self.assertRaises(TypeError): + instance.save() + # Try setting field to object on retrieved object + obj = FloatModel.objects.get(pk=instance.id) obj.size = obj with self.assertRaises(TypeError): obj.save() |
