[1.8.x] Fixed #24714 -- Used more specific assertions than assertEqual in tests.
Backport of eaeea6f947
from master
This commit is contained in:
parent
5105c1628d
commit
c37eb3c870
|
@ -37,7 +37,7 @@ class OnDeleteTests(TestCase):
|
||||||
a = create_a('setnull')
|
a = create_a('setnull')
|
||||||
a.setnull.delete()
|
a.setnull.delete()
|
||||||
a = A.objects.get(pk=a.pk)
|
a = A.objects.get(pk=a.pk)
|
||||||
self.assertEqual(None, a.setnull)
|
self.assertIsNone(a.setnull)
|
||||||
|
|
||||||
def test_setdefault(self):
|
def test_setdefault(self):
|
||||||
a = create_a('setdefault')
|
a = create_a('setdefault')
|
||||||
|
@ -49,7 +49,7 @@ class OnDeleteTests(TestCase):
|
||||||
a = create_a('setdefault_none')
|
a = create_a('setdefault_none')
|
||||||
a.setdefault_none.delete()
|
a.setdefault_none.delete()
|
||||||
a = A.objects.get(pk=a.pk)
|
a = A.objects.get(pk=a.pk)
|
||||||
self.assertEqual(None, a.setdefault_none)
|
self.assertIsNone(a.setdefault_none)
|
||||||
|
|
||||||
def test_cascade(self):
|
def test_cascade(self):
|
||||||
a = create_a('cascade')
|
a = create_a('cascade')
|
||||||
|
@ -119,7 +119,7 @@ class OnDeleteTests(TestCase):
|
||||||
self.assertFalse(R.objects.filter(pk=a.child_setnull_id).exists())
|
self.assertFalse(R.objects.filter(pk=a.child_setnull_id).exists())
|
||||||
|
|
||||||
a = A.objects.get(pk=a.pk)
|
a = A.objects.get(pk=a.pk)
|
||||||
self.assertEqual(None, a.child_setnull)
|
self.assertIsNone(a.child_setnull)
|
||||||
|
|
||||||
def test_setnull_from_parent(self):
|
def test_setnull_from_parent(self):
|
||||||
a = create_a('child_setnull')
|
a = create_a('child_setnull')
|
||||||
|
@ -127,13 +127,13 @@ class OnDeleteTests(TestCase):
|
||||||
self.assertFalse(RChild.objects.filter(pk=a.child_setnull_id).exists())
|
self.assertFalse(RChild.objects.filter(pk=a.child_setnull_id).exists())
|
||||||
|
|
||||||
a = A.objects.get(pk=a.pk)
|
a = A.objects.get(pk=a.pk)
|
||||||
self.assertEqual(None, a.child_setnull)
|
self.assertIsNone(a.child_setnull)
|
||||||
|
|
||||||
def test_o2o_setnull(self):
|
def test_o2o_setnull(self):
|
||||||
a = create_a('o2o_setnull')
|
a = create_a('o2o_setnull')
|
||||||
a.o2o_setnull.delete()
|
a.o2o_setnull.delete()
|
||||||
a = A.objects.get(pk=a.pk)
|
a = A.objects.get(pk=a.pk)
|
||||||
self.assertEqual(None, a.o2o_setnull)
|
self.assertIsNone(a.o2o_setnull)
|
||||||
|
|
||||||
|
|
||||||
class DeletionTests(TestCase):
|
class DeletionTests(TestCase):
|
||||||
|
@ -197,11 +197,11 @@ class DeletionTests(TestCase):
|
||||||
a.cascade.delete()
|
a.cascade.delete()
|
||||||
|
|
||||||
for obj in deleted:
|
for obj in deleted:
|
||||||
self.assertEqual(None, obj.pk)
|
self.assertIsNone(obj.pk)
|
||||||
|
|
||||||
for pk_list in related_setnull_sets:
|
for pk_list in related_setnull_sets:
|
||||||
for a in A.objects.filter(id__in=pk_list):
|
for a in A.objects.filter(id__in=pk_list):
|
||||||
self.assertEqual(None, a.setnull)
|
self.assertIsNone(a.setnull)
|
||||||
|
|
||||||
models.signals.pre_delete.disconnect(pre_delete)
|
models.signals.pre_delete.disconnect(pre_delete)
|
||||||
|
|
||||||
|
|
|
@ -186,9 +186,9 @@ class FieldsTests(SimpleTestCase):
|
||||||
|
|
||||||
def test_integerfield_2(self):
|
def test_integerfield_2(self):
|
||||||
f = IntegerField(required=False)
|
f = IntegerField(required=False)
|
||||||
self.assertEqual(None, f.clean(''))
|
self.assertIsNone(f.clean(''))
|
||||||
self.assertEqual('None', repr(f.clean('')))
|
self.assertEqual('None', repr(f.clean('')))
|
||||||
self.assertEqual(None, f.clean(None))
|
self.assertIsNone(f.clean(None))
|
||||||
self.assertEqual('None', repr(f.clean(None)))
|
self.assertEqual('None', repr(f.clean(None)))
|
||||||
self.assertEqual(1, f.clean('1'))
|
self.assertEqual(1, f.clean('1'))
|
||||||
self.assertIsInstance(f.clean('1'), int)
|
self.assertIsInstance(f.clean('1'), int)
|
||||||
|
@ -285,8 +285,8 @@ class FieldsTests(SimpleTestCase):
|
||||||
|
|
||||||
def test_floatfield_2(self):
|
def test_floatfield_2(self):
|
||||||
f = FloatField(required=False)
|
f = FloatField(required=False)
|
||||||
self.assertEqual(None, f.clean(''))
|
self.assertIsNone(f.clean(''))
|
||||||
self.assertEqual(None, f.clean(None))
|
self.assertIsNone(f.clean(None))
|
||||||
self.assertEqual(1.0, f.clean('1'))
|
self.assertEqual(1.0, f.clean('1'))
|
||||||
self.assertEqual(f.max_value, None)
|
self.assertEqual(f.max_value, None)
|
||||||
self.assertEqual(f.min_value, None)
|
self.assertEqual(f.min_value, None)
|
||||||
|
@ -363,8 +363,8 @@ class FieldsTests(SimpleTestCase):
|
||||||
|
|
||||||
def test_decimalfield_2(self):
|
def test_decimalfield_2(self):
|
||||||
f = DecimalField(max_digits=4, decimal_places=2, required=False)
|
f = DecimalField(max_digits=4, decimal_places=2, required=False)
|
||||||
self.assertEqual(None, f.clean(''))
|
self.assertIsNone(f.clean(''))
|
||||||
self.assertEqual(None, f.clean(None))
|
self.assertIsNone(f.clean(None))
|
||||||
self.assertEqual(f.clean('1'), Decimal("1"))
|
self.assertEqual(f.clean('1'), Decimal("1"))
|
||||||
self.assertEqual(f.max_digits, 4)
|
self.assertEqual(f.max_digits, 4)
|
||||||
self.assertEqual(f.decimal_places, 2)
|
self.assertEqual(f.decimal_places, 2)
|
||||||
|
@ -460,9 +460,9 @@ class FieldsTests(SimpleTestCase):
|
||||||
|
|
||||||
def test_datefield_2(self):
|
def test_datefield_2(self):
|
||||||
f = DateField(required=False)
|
f = DateField(required=False)
|
||||||
self.assertEqual(None, f.clean(None))
|
self.assertIsNone(f.clean(None))
|
||||||
self.assertEqual('None', repr(f.clean(None)))
|
self.assertEqual('None', repr(f.clean(None)))
|
||||||
self.assertEqual(None, f.clean(''))
|
self.assertIsNone(f.clean(''))
|
||||||
self.assertEqual('None', repr(f.clean('')))
|
self.assertEqual('None', repr(f.clean('')))
|
||||||
|
|
||||||
def test_datefield_3(self):
|
def test_datefield_3(self):
|
||||||
|
@ -581,9 +581,9 @@ class FieldsTests(SimpleTestCase):
|
||||||
|
|
||||||
def test_datetimefield_3(self):
|
def test_datetimefield_3(self):
|
||||||
f = DateTimeField(required=False)
|
f = DateTimeField(required=False)
|
||||||
self.assertEqual(None, f.clean(None))
|
self.assertIsNone(f.clean(None))
|
||||||
self.assertEqual('None', repr(f.clean(None)))
|
self.assertEqual('None', repr(f.clean(None)))
|
||||||
self.assertEqual(None, f.clean(''))
|
self.assertIsNone(f.clean(''))
|
||||||
self.assertEqual('None', repr(f.clean('')))
|
self.assertEqual('None', repr(f.clean('')))
|
||||||
|
|
||||||
def test_datetimefield_4(self):
|
def test_datetimefield_4(self):
|
||||||
|
@ -1048,7 +1048,7 @@ class FieldsTests(SimpleTestCase):
|
||||||
|
|
||||||
def test_typedchoicefield_6(self):
|
def test_typedchoicefield_6(self):
|
||||||
f = TypedChoiceField(choices=[(1, "+1"), (-1, "-1")], coerce=int, required=False, empty_value=None)
|
f = TypedChoiceField(choices=[(1, "+1"), (-1, "-1")], coerce=int, required=False, empty_value=None)
|
||||||
self.assertEqual(None, f.clean(''))
|
self.assertIsNone(f.clean(''))
|
||||||
|
|
||||||
def test_typedchoicefield_has_changed(self):
|
def test_typedchoicefield_has_changed(self):
|
||||||
# has_changed should not trigger required validation
|
# has_changed should not trigger required validation
|
||||||
|
@ -1076,15 +1076,15 @@ class FieldsTests(SimpleTestCase):
|
||||||
|
|
||||||
def test_nullbooleanfield_1(self):
|
def test_nullbooleanfield_1(self):
|
||||||
f = NullBooleanField()
|
f = NullBooleanField()
|
||||||
self.assertEqual(None, f.clean(''))
|
self.assertIsNone(f.clean(''))
|
||||||
self.assertEqual(True, f.clean(True))
|
self.assertEqual(True, f.clean(True))
|
||||||
self.assertEqual(False, f.clean(False))
|
self.assertEqual(False, f.clean(False))
|
||||||
self.assertEqual(None, f.clean(None))
|
self.assertIsNone(f.clean(None))
|
||||||
self.assertEqual(False, f.clean('0'))
|
self.assertEqual(False, f.clean('0'))
|
||||||
self.assertEqual(True, f.clean('1'))
|
self.assertEqual(True, f.clean('1'))
|
||||||
self.assertEqual(None, f.clean('2'))
|
self.assertIsNone(f.clean('2'))
|
||||||
self.assertEqual(None, f.clean('3'))
|
self.assertIsNone(f.clean('3'))
|
||||||
self.assertEqual(None, f.clean('hello'))
|
self.assertIsNone(f.clean('hello'))
|
||||||
self.assertEqual(True, f.clean('true'))
|
self.assertEqual(True, f.clean('true'))
|
||||||
self.assertEqual(False, f.clean('false'))
|
self.assertEqual(False, f.clean('false'))
|
||||||
|
|
||||||
|
@ -1101,7 +1101,7 @@ class FieldsTests(SimpleTestCase):
|
||||||
hidden_nullbool1 = NullBooleanField(widget=HiddenInput, initial=True)
|
hidden_nullbool1 = NullBooleanField(widget=HiddenInput, initial=True)
|
||||||
hidden_nullbool2 = NullBooleanField(widget=HiddenInput, initial=False)
|
hidden_nullbool2 = NullBooleanField(widget=HiddenInput, initial=False)
|
||||||
f = HiddenNullBooleanForm({'hidden_nullbool1': 'True', 'hidden_nullbool2': 'False'})
|
f = HiddenNullBooleanForm({'hidden_nullbool1': 'True', 'hidden_nullbool2': 'False'})
|
||||||
self.assertEqual(None, f.full_clean())
|
self.assertIsNone(f.full_clean())
|
||||||
self.assertEqual(True, f.cleaned_data['hidden_nullbool1'])
|
self.assertEqual(True, f.cleaned_data['hidden_nullbool1'])
|
||||||
self.assertEqual(False, f.cleaned_data['hidden_nullbool2'])
|
self.assertEqual(False, f.cleaned_data['hidden_nullbool2'])
|
||||||
|
|
||||||
|
@ -1115,10 +1115,10 @@ class FieldsTests(SimpleTestCase):
|
||||||
nullbool1 = NullBooleanField(widget=RadioSelect(choices=NULLBOOL_CHOICES))
|
nullbool1 = NullBooleanField(widget=RadioSelect(choices=NULLBOOL_CHOICES))
|
||||||
nullbool2 = NullBooleanField(widget=RadioSelect(choices=NULLBOOL_CHOICES))
|
nullbool2 = NullBooleanField(widget=RadioSelect(choices=NULLBOOL_CHOICES))
|
||||||
f = MySQLNullBooleanForm({'nullbool0': '1', 'nullbool1': '0', 'nullbool2': ''})
|
f = MySQLNullBooleanForm({'nullbool0': '1', 'nullbool1': '0', 'nullbool2': ''})
|
||||||
self.assertEqual(None, f.full_clean())
|
self.assertIsNone(f.full_clean())
|
||||||
self.assertEqual(True, f.cleaned_data['nullbool0'])
|
self.assertEqual(True, f.cleaned_data['nullbool0'])
|
||||||
self.assertEqual(False, f.cleaned_data['nullbool1'])
|
self.assertEqual(False, f.cleaned_data['nullbool1'])
|
||||||
self.assertEqual(None, f.cleaned_data['nullbool2'])
|
self.assertIsNone(f.cleaned_data['nullbool2'])
|
||||||
|
|
||||||
def test_nullbooleanfield_changed(self):
|
def test_nullbooleanfield_changed(self):
|
||||||
f = NullBooleanField()
|
f = NullBooleanField()
|
||||||
|
@ -1221,7 +1221,7 @@ class FieldsTests(SimpleTestCase):
|
||||||
def test_typedmultiplechoicefield_7(self):
|
def test_typedmultiplechoicefield_7(self):
|
||||||
# If you want cleaning an empty value to return a different type, tell the field
|
# If you want cleaning an empty value to return a different type, tell the field
|
||||||
f = TypedMultipleChoiceField(choices=[(1, "+1"), (-1, "-1")], coerce=int, required=False, empty_value=None)
|
f = TypedMultipleChoiceField(choices=[(1, "+1"), (-1, "-1")], coerce=int, required=False, empty_value=None)
|
||||||
self.assertEqual(None, f.clean([]))
|
self.assertIsNone(f.clean([]))
|
||||||
|
|
||||||
def test_typedmultiplechoicefield_has_changed(self):
|
def test_typedmultiplechoicefield_has_changed(self):
|
||||||
# has_changed should not trigger required validation
|
# has_changed should not trigger required validation
|
||||||
|
@ -1377,10 +1377,10 @@ class FieldsTests(SimpleTestCase):
|
||||||
f = SplitDateTimeField(required=False)
|
f = SplitDateTimeField(required=False)
|
||||||
self.assertEqual(datetime.datetime(2006, 1, 10, 7, 30), f.clean([datetime.date(2006, 1, 10), datetime.time(7, 30)]))
|
self.assertEqual(datetime.datetime(2006, 1, 10, 7, 30), f.clean([datetime.date(2006, 1, 10), datetime.time(7, 30)]))
|
||||||
self.assertEqual(datetime.datetime(2006, 1, 10, 7, 30), f.clean(['2006-01-10', '07:30']))
|
self.assertEqual(datetime.datetime(2006, 1, 10, 7, 30), f.clean(['2006-01-10', '07:30']))
|
||||||
self.assertEqual(None, f.clean(None))
|
self.assertIsNone(f.clean(None))
|
||||||
self.assertEqual(None, f.clean(''))
|
self.assertIsNone(f.clean(''))
|
||||||
self.assertEqual(None, f.clean(['']))
|
self.assertIsNone(f.clean(['']))
|
||||||
self.assertEqual(None, f.clean(['', '']))
|
self.assertIsNone(f.clean(['', '']))
|
||||||
self.assertRaisesMessage(ValidationError, "'Enter a list of values.'", f.clean, 'hello')
|
self.assertRaisesMessage(ValidationError, "'Enter a list of values.'", f.clean, 'hello')
|
||||||
six.assertRaisesRegex(self, ValidationError, "'Enter a valid date\.', u?'Enter a valid time\.'", f.clean, ['hello', 'there'])
|
six.assertRaisesRegex(self, ValidationError, "'Enter a valid date\.', u?'Enter a valid time\.'", f.clean, ['hello', 'there'])
|
||||||
self.assertRaisesMessage(ValidationError, "'Enter a valid time.'", f.clean, ['2006-01-10', 'there'])
|
self.assertRaisesMessage(ValidationError, "'Enter a valid time.'", f.clean, ['2006-01-10', 'there'])
|
||||||
|
|
|
@ -2068,9 +2068,9 @@ class FormsTestCase(TestCase):
|
||||||
# Empty values for fields will NOT raise a `required` error on an
|
# Empty values for fields will NOT raise a `required` error on an
|
||||||
# optional `MultiValueField`
|
# optional `MultiValueField`
|
||||||
f = PhoneField(required=False)
|
f = PhoneField(required=False)
|
||||||
self.assertEqual(None, f.clean(''))
|
self.assertIsNone(f.clean(''))
|
||||||
self.assertEqual(None, f.clean(None))
|
self.assertIsNone(f.clean(None))
|
||||||
self.assertEqual(None, f.clean([]))
|
self.assertIsNone(f.clean([]))
|
||||||
self.assertEqual('+61. ext. (label: )', f.clean(['+61']))
|
self.assertEqual('+61. ext. (label: )', f.clean(['+61']))
|
||||||
self.assertEqual('+61.287654321 ext. 123 (label: )', f.clean(['+61', '287654321', '123']))
|
self.assertEqual('+61.287654321 ext. 123 (label: )', f.clean(['+61', '287654321', '123']))
|
||||||
self.assertEqual('+61.287654321 ext. 123 (label: Home)', f.clean(['+61', '287654321', '123', 'Home']))
|
self.assertEqual('+61.287654321 ext. 123 (label: Home)', f.clean(['+61', '287654321', '123', 'Home']))
|
||||||
|
@ -2095,9 +2095,9 @@ class FormsTestCase(TestCase):
|
||||||
# For an optional `MultiValueField` with `require_all_fields=False`, we
|
# For an optional `MultiValueField` with `require_all_fields=False`, we
|
||||||
# don't get any `required` error but we still get `incomplete` errors.
|
# don't get any `required` error but we still get `incomplete` errors.
|
||||||
f = PhoneField(required=False, require_all_fields=False)
|
f = PhoneField(required=False, require_all_fields=False)
|
||||||
self.assertEqual(None, f.clean(''))
|
self.assertIsNone(f.clean(''))
|
||||||
self.assertEqual(None, f.clean(None))
|
self.assertIsNone(f.clean(None))
|
||||||
self.assertEqual(None, f.clean([]))
|
self.assertIsNone(f.clean([]))
|
||||||
self.assertRaisesMessage(ValidationError, "'Enter a complete value.'", f.clean, ['+61'])
|
self.assertRaisesMessage(ValidationError, "'Enter a complete value.'", f.clean, ['+61'])
|
||||||
self.assertEqual('+61.287654321 ext. 123 (label: )', f.clean(['+61', '287654321', '123']))
|
self.assertEqual('+61.287654321 ext. 123 (label: )', f.clean(['+61', '287654321', '123']))
|
||||||
six.assertRaisesRegex(self, ValidationError,
|
six.assertRaisesRegex(self, ValidationError,
|
||||||
|
|
|
@ -334,7 +334,7 @@ class EmptyLabelTestCase(TestCase):
|
||||||
|
|
||||||
def test_get_display_value_on_none(self):
|
def test_get_display_value_on_none(self):
|
||||||
m = ChoiceModel.objects.create(name='test', choice='', choice_integer=None)
|
m = ChoiceModel.objects.create(name='test', choice='', choice_integer=None)
|
||||||
self.assertEqual(None, m.choice_integer)
|
self.assertIsNone(m.choice_integer)
|
||||||
self.assertEqual('No Preference', m.get_choice_integer_display())
|
self.assertEqual('No Preference', m.get_choice_integer_display())
|
||||||
|
|
||||||
def test_html_rendering_of_prepopulated_models(self):
|
def test_html_rendering_of_prepopulated_models(self):
|
||||||
|
|
|
@ -35,7 +35,7 @@ class FormMixinTests(TestCase):
|
||||||
request = get_request
|
request = get_request
|
||||||
|
|
||||||
default_kwargs = TestFormMixin().get_form_kwargs()
|
default_kwargs = TestFormMixin().get_form_kwargs()
|
||||||
self.assertEqual(None, default_kwargs.get('prefix'))
|
self.assertIsNone(default_kwargs.get('prefix'))
|
||||||
|
|
||||||
set_mixin = TestFormMixin()
|
set_mixin = TestFormMixin()
|
||||||
set_mixin.prefix = test_string
|
set_mixin.prefix = test_string
|
||||||
|
|
|
@ -118,7 +118,7 @@ class DataSourceTest(unittest.TestCase):
|
||||||
# Now checking the field names.
|
# Now checking the field names.
|
||||||
flds = layer.fields
|
flds = layer.fields
|
||||||
for f in flds:
|
for f in flds:
|
||||||
self.assertEqual(True, f in source.fields)
|
self.assertIn(f, source.fields)
|
||||||
|
|
||||||
# Negative FIDs are not allowed.
|
# Negative FIDs are not allowed.
|
||||||
self.assertRaises(OGRIndexError, layer.__getitem__, -1)
|
self.assertRaises(OGRIndexError, layer.__getitem__, -1)
|
||||||
|
@ -199,7 +199,7 @@ class DataSourceTest(unittest.TestCase):
|
||||||
|
|
||||||
# Testing Feature.__iter__
|
# Testing Feature.__iter__
|
||||||
for fld in feat:
|
for fld in feat:
|
||||||
self.assertEqual(True, fld.name in source.fields.keys())
|
self.assertIn(fld.name, source.fields.keys())
|
||||||
|
|
||||||
def test05_geometries(self):
|
def test05_geometries(self):
|
||||||
"Testing Geometries from Data Source Features."
|
"Testing Geometries from Data Source Features."
|
||||||
|
@ -229,7 +229,7 @@ class DataSourceTest(unittest.TestCase):
|
||||||
lyr = ds[0]
|
lyr = ds[0]
|
||||||
|
|
||||||
# When not set, it should be None.
|
# When not set, it should be None.
|
||||||
self.assertEqual(None, lyr.spatial_filter)
|
self.assertIsNone(lyr.spatial_filter)
|
||||||
|
|
||||||
# Must be set a/an OGRGeometry or 4-tuple.
|
# Must be set a/an OGRGeometry or 4-tuple.
|
||||||
self.assertRaises(TypeError, lyr._set_spatial_filter, 'foo')
|
self.assertRaises(TypeError, lyr._set_spatial_filter, 'foo')
|
||||||
|
|
|
@ -255,4 +255,4 @@ class SpatialRefTest(unittest.TestCase):
|
||||||
self.assertEqual('WGS_1984', s1['DATUM'])
|
self.assertEqual('WGS_1984', s1['DATUM'])
|
||||||
self.assertEqual('EPSG', s1['AUTHORITY'])
|
self.assertEqual('EPSG', s1['AUTHORITY'])
|
||||||
self.assertEqual(4326, int(s1['AUTHORITY', 1]))
|
self.assertEqual(4326, int(s1['AUTHORITY', 1]))
|
||||||
self.assertEqual(None, s1['FOOBAR'])
|
self.assertIsNone(s1['FOOBAR'])
|
||||||
|
|
|
@ -228,8 +228,8 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
|
||||||
self.assertEqual(pnt.geom_typeid, 0)
|
self.assertEqual(pnt.geom_typeid, 0)
|
||||||
self.assertEqual(p.x, pnt.x)
|
self.assertEqual(p.x, pnt.x)
|
||||||
self.assertEqual(p.y, pnt.y)
|
self.assertEqual(p.y, pnt.y)
|
||||||
self.assertEqual(True, pnt == fromstr(p.wkt))
|
self.assertEqual(pnt, fromstr(p.wkt))
|
||||||
self.assertEqual(False, pnt == prev)
|
self.assertEqual(False, pnt == prev) # Use assertEqual to test __eq__
|
||||||
|
|
||||||
# Making sure that the point's X, Y components are what we expect
|
# Making sure that the point's X, Y components are what we expect
|
||||||
self.assertAlmostEqual(p.x, pnt.tuple[0], 9)
|
self.assertAlmostEqual(p.x, pnt.tuple[0], 9)
|
||||||
|
@ -245,7 +245,7 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
|
||||||
set_tup2 = (5.23, 2.71, 3.14)
|
set_tup2 = (5.23, 2.71, 3.14)
|
||||||
else:
|
else:
|
||||||
self.assertEqual(False, pnt.hasz)
|
self.assertEqual(False, pnt.hasz)
|
||||||
self.assertEqual(None, pnt.z)
|
self.assertIsNone(pnt.z)
|
||||||
tup_args = (p.x, p.y)
|
tup_args = (p.x, p.y)
|
||||||
set_tup1 = (2.71, 3.14)
|
set_tup1 = (2.71, 3.14)
|
||||||
set_tup2 = (3.14, 2.71)
|
set_tup2 = (3.14, 2.71)
|
||||||
|
@ -256,8 +256,8 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
|
||||||
# Now testing the different constructors
|
# Now testing the different constructors
|
||||||
pnt2 = Point(tup_args) # e.g., Point((1, 2))
|
pnt2 = Point(tup_args) # e.g., Point((1, 2))
|
||||||
pnt3 = Point(*tup_args) # e.g., Point(1, 2)
|
pnt3 = Point(*tup_args) # e.g., Point(1, 2)
|
||||||
self.assertEqual(True, pnt == pnt2)
|
self.assertEqual(pnt, pnt2)
|
||||||
self.assertEqual(True, pnt == pnt3)
|
self.assertEqual(pnt, pnt3)
|
||||||
|
|
||||||
# Now testing setting the x and y
|
# Now testing setting the x and y
|
||||||
pnt.y = 3.14
|
pnt.y = 3.14
|
||||||
|
@ -306,8 +306,8 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
|
||||||
if hasattr(l, 'tup'):
|
if hasattr(l, 'tup'):
|
||||||
self.assertEqual(l.tup, ls.tuple)
|
self.assertEqual(l.tup, ls.tuple)
|
||||||
|
|
||||||
self.assertEqual(True, ls == fromstr(l.wkt))
|
self.assertEqual(ls, fromstr(l.wkt))
|
||||||
self.assertEqual(False, ls == prev)
|
self.assertEqual(False, ls == prev) # Use assertEqual to test __eq__
|
||||||
self.assertRaises(GEOSIndexError, ls.__getitem__, len(ls))
|
self.assertRaises(GEOSIndexError, ls.__getitem__, len(ls))
|
||||||
prev = ls
|
prev = ls
|
||||||
|
|
||||||
|
@ -331,8 +331,8 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
|
||||||
self.assertAlmostEqual(l.centroid[0], ml.centroid.x, 9)
|
self.assertAlmostEqual(l.centroid[0], ml.centroid.x, 9)
|
||||||
self.assertAlmostEqual(l.centroid[1], ml.centroid.y, 9)
|
self.assertAlmostEqual(l.centroid[1], ml.centroid.y, 9)
|
||||||
|
|
||||||
self.assertEqual(True, ml == fromstr(l.wkt))
|
self.assertEqual(ml, fromstr(l.wkt))
|
||||||
self.assertEqual(False, ml == prev)
|
self.assertEqual(False, ml == prev) # Use assertEqual to test __eq__
|
||||||
prev = ml
|
prev = ml
|
||||||
|
|
||||||
for ls in ml:
|
for ls in ml:
|
||||||
|
@ -395,9 +395,10 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
|
||||||
self.assertAlmostEqual(p.centroid[1], poly.centroid.tuple[1], 9)
|
self.assertAlmostEqual(p.centroid[1], poly.centroid.tuple[1], 9)
|
||||||
|
|
||||||
# Testing the geometry equivalence
|
# Testing the geometry equivalence
|
||||||
self.assertEqual(True, poly == fromstr(p.wkt))
|
self.assertEqual(poly, fromstr(p.wkt))
|
||||||
self.assertEqual(False, poly == prev) # Should not be equal to previous geometry
|
# Should not be equal to previous geometry
|
||||||
self.assertEqual(True, poly != prev)
|
self.assertEqual(False, poly == prev) # Use assertEqual to test __eq__
|
||||||
|
self.assertNotEqual(poly, prev) # Use assertNotEqual to test __ne__
|
||||||
|
|
||||||
# Testing the exterior ring
|
# Testing the exterior ring
|
||||||
ring = poly.exterior_ring
|
ring = poly.exterior_ring
|
||||||
|
|
|
@ -291,7 +291,7 @@ class RelatedGeoModelTest(TestCase):
|
||||||
Book.objects.create(title='Without Author')
|
Book.objects.create(title='Without Author')
|
||||||
b = Book.objects.select_related('author').get(title='Without Author')
|
b = Book.objects.select_related('author').get(title='Without Author')
|
||||||
# Should be `None`, and not a 'dummy' model.
|
# Should be `None`, and not a 'dummy' model.
|
||||||
self.assertEqual(None, b.author)
|
self.assertIsNone(b.author)
|
||||||
|
|
||||||
@skipUnlessDBFeature("supports_collect_aggr")
|
@skipUnlessDBFeature("supports_collect_aggr")
|
||||||
@ignore_warnings(category=RemovedInDjango20Warning)
|
@ignore_warnings(category=RemovedInDjango20Warning)
|
||||||
|
|
|
@ -35,16 +35,16 @@ class GeoIPTest(unittest.TestCase):
|
||||||
g3 = GeoIP.open(path, 0) # MaxMind Python API syntax.
|
g3 = GeoIP.open(path, 0) # MaxMind Python API syntax.
|
||||||
|
|
||||||
for g in (g1, g2, g3):
|
for g in (g1, g2, g3):
|
||||||
self.assertEqual(True, bool(g._country))
|
self.assertTrue(g._country)
|
||||||
self.assertEqual(True, bool(g._city))
|
self.assertTrue(g._city)
|
||||||
|
|
||||||
# Only passing in the location of one database.
|
# Only passing in the location of one database.
|
||||||
city = os.path.join(path, 'GeoLiteCity.dat')
|
city = os.path.join(path, 'GeoLiteCity.dat')
|
||||||
cntry = os.path.join(path, 'GeoIP.dat')
|
cntry = os.path.join(path, 'GeoIP.dat')
|
||||||
g4 = GeoIP(city, country='')
|
g4 = GeoIP(city, country='')
|
||||||
self.assertEqual(None, g4._country)
|
self.assertIsNone(g4._country)
|
||||||
g5 = GeoIP(cntry, city='')
|
g5 = GeoIP(cntry, city='')
|
||||||
self.assertEqual(None, g5._city)
|
self.assertIsNone(g5._city)
|
||||||
|
|
||||||
# Improper parameters.
|
# Improper parameters.
|
||||||
bad_params = (23, 'foo', 15.23)
|
bad_params = (23, 'foo', 15.23)
|
||||||
|
|
|
@ -56,7 +56,7 @@ class SpatialRefSysTest(unittest.TestCase):
|
||||||
# the testing with the 'startswith' flag.
|
# the testing with the 'startswith' flag.
|
||||||
auth_name, oracle_flag = sd['auth_name']
|
auth_name, oracle_flag = sd['auth_name']
|
||||||
if postgis or (oracle and oracle_flag):
|
if postgis or (oracle and oracle_flag):
|
||||||
self.assertEqual(True, srs.auth_name.startswith(auth_name))
|
self.assertTrue(srs.auth_name.startswith(auth_name))
|
||||||
|
|
||||||
self.assertEqual(sd['auth_srid'], srs.auth_srid)
|
self.assertEqual(sd['auth_srid'], srs.auth_srid)
|
||||||
|
|
||||||
|
@ -71,14 +71,14 @@ class SpatialRefSysTest(unittest.TestCase):
|
||||||
"""
|
"""
|
||||||
for sd in test_srs:
|
for sd in test_srs:
|
||||||
sr = SpatialRefSys.objects.get(srid=sd['srid'])
|
sr = SpatialRefSys.objects.get(srid=sd['srid'])
|
||||||
self.assertEqual(True, sr.spheroid.startswith(sd['spheroid']))
|
self.assertTrue(sr.spheroid.startswith(sd['spheroid']))
|
||||||
self.assertEqual(sd['geographic'], sr.geographic)
|
self.assertEqual(sd['geographic'], sr.geographic)
|
||||||
self.assertEqual(sd['projected'], sr.projected)
|
self.assertEqual(sd['projected'], sr.projected)
|
||||||
|
|
||||||
if not (spatialite and not sd['spatialite']):
|
if not (spatialite and not sd['spatialite']):
|
||||||
# Can't get 'NAD83 / Texas South Central' from PROJ.4 string
|
# Can't get 'NAD83 / Texas South Central' from PROJ.4 string
|
||||||
# on SpatiaLite
|
# on SpatiaLite
|
||||||
self.assertEqual(True, sr.name.startswith(sd['name']))
|
self.assertTrue(sr.name.startswith(sd['name']))
|
||||||
|
|
||||||
# Testing the SpatialReference object directly.
|
# Testing the SpatialReference object directly.
|
||||||
if postgis or spatialite:
|
if postgis or spatialite:
|
||||||
|
|
|
@ -130,13 +130,13 @@ class TranslationTests(TestCase):
|
||||||
|
|
||||||
# It should be possible to compare *_lazy objects.
|
# It should be possible to compare *_lazy objects.
|
||||||
s1 = ugettext_lazy('Add %(name)s')
|
s1 = ugettext_lazy('Add %(name)s')
|
||||||
self.assertEqual(True, s == s1)
|
self.assertEqual(s, s1)
|
||||||
s2 = gettext_lazy('Add %(name)s')
|
s2 = gettext_lazy('Add %(name)s')
|
||||||
s3 = gettext_lazy('Add %(name)s')
|
s3 = gettext_lazy('Add %(name)s')
|
||||||
self.assertEqual(True, s2 == s3)
|
self.assertEqual(s2, s3)
|
||||||
self.assertEqual(True, s == s2)
|
self.assertEqual(s, s2)
|
||||||
s4 = ugettext_lazy('Some other string')
|
s4 = ugettext_lazy('Some other string')
|
||||||
self.assertEqual(False, s == s4)
|
self.assertNotEqual(s, s4)
|
||||||
|
|
||||||
@skipUnless(six.PY2, "No more bytestring translations on PY3")
|
@skipUnless(six.PY2, "No more bytestring translations on PY3")
|
||||||
def test_lazy_and_bytestrings(self):
|
def test_lazy_and_bytestrings(self):
|
||||||
|
@ -543,7 +543,7 @@ class FormattingTests(TestCase):
|
||||||
'time_field': '20:50',
|
'time_field': '20:50',
|
||||||
'integer_field': '1.234',
|
'integer_field': '1.234',
|
||||||
})
|
})
|
||||||
self.assertEqual(False, form.is_valid())
|
self.assertFalse(form.is_valid())
|
||||||
self.assertEqual(['Introdu\xefu un n\xfamero.'], form.errors['float_field'])
|
self.assertEqual(['Introdu\xefu un n\xfamero.'], form.errors['float_field'])
|
||||||
self.assertEqual(['Introdu\xefu un n\xfamero.'], form.errors['decimal_field'])
|
self.assertEqual(['Introdu\xefu un n\xfamero.'], form.errors['decimal_field'])
|
||||||
self.assertEqual(['Introdu\xefu una data v\xe0lida.'], form.errors['date_field'])
|
self.assertEqual(['Introdu\xefu una data v\xe0lida.'], form.errors['date_field'])
|
||||||
|
@ -555,7 +555,7 @@ class FormattingTests(TestCase):
|
||||||
'date_field_day': '31',
|
'date_field_day': '31',
|
||||||
'date_field_year': '2009'
|
'date_field_year': '2009'
|
||||||
})
|
})
|
||||||
self.assertEqual(True, form2.is_valid())
|
self.assertTrue(form2.is_valid())
|
||||||
self.assertEqual(datetime.date(2009, 12, 31), form2.cleaned_data['date_field'])
|
self.assertEqual(datetime.date(2009, 12, 31), form2.cleaned_data['date_field'])
|
||||||
self.assertHTMLEqual(
|
self.assertHTMLEqual(
|
||||||
'<select name="mydate_month" id="id_mydate_month">\n<option value="0">---</option>\n<option value="1">gener</option>\n<option value="2">febrer</option>\n<option value="3">mar\xe7</option>\n<option value="4">abril</option>\n<option value="5">maig</option>\n<option value="6">juny</option>\n<option value="7">juliol</option>\n<option value="8">agost</option>\n<option value="9">setembre</option>\n<option value="10">octubre</option>\n<option value="11">novembre</option>\n<option value="12" selected="selected">desembre</option>\n</select>\n<select name="mydate_day" id="id_mydate_day">\n<option value="0">---</option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31" selected="selected">31</option>\n</select>\n<select name="mydate_year" id="id_mydate_year">\n<option value="0">---</option>\n<option value="2009" selected="selected">2009</option>\n<option value="2010">2010</option>\n<option value="2011">2011</option>\n<option value="2012">2012</option>\n<option value="2013">2013</option>\n<option value="2014">2014</option>\n<option value="2015">2015</option>\n<option value="2016">2016</option>\n<option value="2017">2017</option>\n<option value="2018">2018</option>\n</select>',
|
'<select name="mydate_month" id="id_mydate_month">\n<option value="0">---</option>\n<option value="1">gener</option>\n<option value="2">febrer</option>\n<option value="3">mar\xe7</option>\n<option value="4">abril</option>\n<option value="5">maig</option>\n<option value="6">juny</option>\n<option value="7">juliol</option>\n<option value="8">agost</option>\n<option value="9">setembre</option>\n<option value="10">octubre</option>\n<option value="11">novembre</option>\n<option value="12" selected="selected">desembre</option>\n</select>\n<select name="mydate_day" id="id_mydate_day">\n<option value="0">---</option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31" selected="selected">31</option>\n</select>\n<select name="mydate_year" id="id_mydate_year">\n<option value="0">---</option>\n<option value="2009" selected="selected">2009</option>\n<option value="2010">2010</option>\n<option value="2011">2011</option>\n<option value="2012">2012</option>\n<option value="2013">2013</option>\n<option value="2014">2014</option>\n<option value="2015">2015</option>\n<option value="2016">2016</option>\n<option value="2017">2017</option>\n<option value="2018">2018</option>\n</select>',
|
||||||
|
@ -630,7 +630,7 @@ class FormattingTests(TestCase):
|
||||||
'time_field': '20:50',
|
'time_field': '20:50',
|
||||||
'integer_field': '1.234',
|
'integer_field': '1.234',
|
||||||
})
|
})
|
||||||
self.assertEqual(True, form3.is_valid())
|
self.assertTrue(form3.is_valid())
|
||||||
self.assertEqual(decimal.Decimal('66666.666'), form3.cleaned_data['decimal_field'])
|
self.assertEqual(decimal.Decimal('66666.666'), form3.cleaned_data['decimal_field'])
|
||||||
self.assertEqual(99999.999, form3.cleaned_data['float_field'])
|
self.assertEqual(99999.999, form3.cleaned_data['float_field'])
|
||||||
self.assertEqual(datetime.date(2009, 12, 31), form3.cleaned_data['date_field'])
|
self.assertEqual(datetime.date(2009, 12, 31), form3.cleaned_data['date_field'])
|
||||||
|
@ -660,7 +660,7 @@ class FormattingTests(TestCase):
|
||||||
'time_field': '20:50',
|
'time_field': '20:50',
|
||||||
'integer_field': '1234',
|
'integer_field': '1234',
|
||||||
})
|
})
|
||||||
self.assertEqual(True, form4.is_valid())
|
self.assertTrue(form4.is_valid())
|
||||||
self.assertEqual(decimal.Decimal('66666.666'), form4.cleaned_data['decimal_field'])
|
self.assertEqual(decimal.Decimal('66666.666'), form4.cleaned_data['decimal_field'])
|
||||||
self.assertEqual(99999.999, form4.cleaned_data['float_field'])
|
self.assertEqual(99999.999, form4.cleaned_data['float_field'])
|
||||||
self.assertEqual(datetime.date(2009, 12, 31), form4.cleaned_data['date_field'])
|
self.assertEqual(datetime.date(2009, 12, 31), form4.cleaned_data['date_field'])
|
||||||
|
@ -673,7 +673,7 @@ class FormattingTests(TestCase):
|
||||||
'date_field_day': '31',
|
'date_field_day': '31',
|
||||||
'date_field_year': '2009'
|
'date_field_year': '2009'
|
||||||
})
|
})
|
||||||
self.assertEqual(True, form5.is_valid())
|
self.assertTrue(form5.is_valid())
|
||||||
self.assertEqual(datetime.date(2009, 12, 31), form5.cleaned_data['date_field'])
|
self.assertEqual(datetime.date(2009, 12, 31), form5.cleaned_data['date_field'])
|
||||||
self.assertHTMLEqual(
|
self.assertHTMLEqual(
|
||||||
'<select name="mydate_day" id="id_mydate_day">\n<option value="0">---</option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31" selected="selected">31</option>\n</select>\n<select name="mydate_month" id="id_mydate_month">\n<option value="0">---</option>\n<option value="1">gener</option>\n<option value="2">febrer</option>\n<option value="3">mar\xe7</option>\n<option value="4">abril</option>\n<option value="5">maig</option>\n<option value="6">juny</option>\n<option value="7">juliol</option>\n<option value="8">agost</option>\n<option value="9">setembre</option>\n<option value="10">octubre</option>\n<option value="11">novembre</option>\n<option value="12" selected="selected">desembre</option>\n</select>\n<select name="mydate_year" id="id_mydate_year">\n<option value="0">---</option>\n<option value="2009" selected="selected">2009</option>\n<option value="2010">2010</option>\n<option value="2011">2011</option>\n<option value="2012">2012</option>\n<option value="2013">2013</option>\n<option value="2014">2014</option>\n<option value="2015">2015</option>\n<option value="2016">2016</option>\n<option value="2017">2017</option>\n<option value="2018">2018</option>\n</select>',
|
'<select name="mydate_day" id="id_mydate_day">\n<option value="0">---</option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31" selected="selected">31</option>\n</select>\n<select name="mydate_month" id="id_mydate_month">\n<option value="0">---</option>\n<option value="1">gener</option>\n<option value="2">febrer</option>\n<option value="3">mar\xe7</option>\n<option value="4">abril</option>\n<option value="5">maig</option>\n<option value="6">juny</option>\n<option value="7">juliol</option>\n<option value="8">agost</option>\n<option value="9">setembre</option>\n<option value="10">octubre</option>\n<option value="11">novembre</option>\n<option value="12" selected="selected">desembre</option>\n</select>\n<select name="mydate_year" id="id_mydate_year">\n<option value="0">---</option>\n<option value="2009" selected="selected">2009</option>\n<option value="2010">2010</option>\n<option value="2011">2011</option>\n<option value="2012">2012</option>\n<option value="2013">2013</option>\n<option value="2014">2014</option>\n<option value="2015">2015</option>\n<option value="2016">2016</option>\n<option value="2017">2017</option>\n<option value="2018">2018</option>\n</select>',
|
||||||
|
@ -732,7 +732,7 @@ class FormattingTests(TestCase):
|
||||||
'time_field': '20:50',
|
'time_field': '20:50',
|
||||||
'integer_field': '1234',
|
'integer_field': '1234',
|
||||||
})
|
})
|
||||||
self.assertEqual(True, form5.is_valid())
|
self.assertTrue(form5.is_valid())
|
||||||
self.assertEqual(decimal.Decimal('66666.666'), form5.cleaned_data['decimal_field'])
|
self.assertEqual(decimal.Decimal('66666.666'), form5.cleaned_data['decimal_field'])
|
||||||
self.assertEqual(99999.999, form5.cleaned_data['float_field'])
|
self.assertEqual(99999.999, form5.cleaned_data['float_field'])
|
||||||
self.assertEqual(datetime.date(2009, 12, 31), form5.cleaned_data['date_field'])
|
self.assertEqual(datetime.date(2009, 12, 31), form5.cleaned_data['date_field'])
|
||||||
|
@ -745,7 +745,7 @@ class FormattingTests(TestCase):
|
||||||
'date_field_day': '31',
|
'date_field_day': '31',
|
||||||
'date_field_year': '2009'
|
'date_field_year': '2009'
|
||||||
})
|
})
|
||||||
self.assertEqual(True, form6.is_valid())
|
self.assertTrue(form6.is_valid())
|
||||||
self.assertEqual(datetime.date(2009, 12, 31), form6.cleaned_data['date_field'])
|
self.assertEqual(datetime.date(2009, 12, 31), form6.cleaned_data['date_field'])
|
||||||
self.assertHTMLEqual(
|
self.assertHTMLEqual(
|
||||||
'<select name="mydate_month" id="id_mydate_month">\n<option value="0">---</option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12" selected="selected">December</option>\n</select>\n<select name="mydate_day" id="id_mydate_day">\n<option value="0">---</option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31" selected="selected">31</option>\n</select>\n<select name="mydate_year" id="id_mydate_year">\n<option value="0">---</option>\n<option value="2009" selected="selected">2009</option>\n<option value="2010">2010</option>\n<option value="2011">2011</option>\n<option value="2012">2012</option>\n<option value="2013">2013</option>\n<option value="2014">2014</option>\n<option value="2015">2015</option>\n<option value="2016">2016</option>\n<option value="2017">2017</option>\n<option value="2018">2018</option>\n</select>',
|
'<select name="mydate_month" id="id_mydate_month">\n<option value="0">---</option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12" selected="selected">December</option>\n</select>\n<select name="mydate_day" id="id_mydate_day">\n<option value="0">---</option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31" selected="selected">31</option>\n</select>\n<select name="mydate_year" id="id_mydate_year">\n<option value="0">---</option>\n<option value="2009" selected="selected">2009</option>\n<option value="2010">2010</option>\n<option value="2011">2011</option>\n<option value="2012">2012</option>\n<option value="2013">2013</option>\n<option value="2014">2014</option>\n<option value="2015">2015</option>\n<option value="2016">2016</option>\n<option value="2017">2017</option>\n<option value="2018">2018</option>\n</select>',
|
||||||
|
@ -774,7 +774,7 @@ class FormattingTests(TestCase):
|
||||||
'cents_paid': decimal.Decimal('59.47'),
|
'cents_paid': decimal.Decimal('59.47'),
|
||||||
'products_delivered': 12000,
|
'products_delivered': 12000,
|
||||||
})
|
})
|
||||||
self.assertEqual(True, form6.is_valid())
|
self.assertTrue(form6.is_valid())
|
||||||
self.assertHTMLEqual(
|
self.assertHTMLEqual(
|
||||||
form6.as_ul(),
|
form6.as_ul(),
|
||||||
'<li><label for="id_name">Name:</label> <input id="id_name" type="text" name="name" value="acme" maxlength="50" /></li>\n<li><label for="id_date_added">Date added:</label> <input type="text" name="date_added" value="31.12.2009 06:00:00" id="id_date_added" /></li>\n<li><label for="id_cents_paid">Cents paid:</label> <input type="text" name="cents_paid" value="59,47" id="id_cents_paid" /></li>\n<li><label for="id_products_delivered">Products delivered:</label> <input type="text" name="products_delivered" value="12000" id="id_products_delivered" /></li>'
|
'<li><label for="id_name">Name:</label> <input id="id_name" type="text" name="name" value="acme" maxlength="50" /></li>\n<li><label for="id_date_added">Date added:</label> <input type="text" name="date_added" value="31.12.2009 06:00:00" id="id_date_added" /></li>\n<li><label for="id_cents_paid">Cents paid:</label> <input type="text" name="cents_paid" value="59,47" id="id_cents_paid" /></li>\n<li><label for="id_products_delivered">Products delivered:</label> <input type="text" name="products_delivered" value="12000" id="id_products_delivered" /></li>'
|
||||||
|
|
|
@ -478,7 +478,7 @@ class ValidationTest(test.TestCase):
|
||||||
|
|
||||||
def test_nullable_integerfield_cleans_none_on_null_and_blank_true(self):
|
def test_nullable_integerfield_cleans_none_on_null_and_blank_true(self):
|
||||||
f = models.IntegerField(null=True, blank=True)
|
f = models.IntegerField(null=True, blank=True)
|
||||||
self.assertEqual(None, f.clean(None, None))
|
self.assertIsNone(f.clean(None, None))
|
||||||
|
|
||||||
def test_integerfield_raises_error_on_empty_input(self):
|
def test_integerfield_raises_error_on_empty_input(self):
|
||||||
f = models.IntegerField(null=False)
|
f = models.IntegerField(null=False)
|
||||||
|
|
|
@ -536,7 +536,7 @@ class QueryTestCase(TestCase):
|
||||||
"ForeignKey.validate() uses the correct database"
|
"ForeignKey.validate() uses the correct database"
|
||||||
mickey = Person.objects.using('other').create(name="Mickey")
|
mickey = Person.objects.using('other').create(name="Mickey")
|
||||||
pluto = Pet.objects.using('other').create(name="Pluto", owner=mickey)
|
pluto = Pet.objects.using('other').create(name="Pluto", owner=mickey)
|
||||||
self.assertEqual(None, pluto.full_clean())
|
self.assertIsNone(pluto.full_clean())
|
||||||
|
|
||||||
def test_o2o_separation(self):
|
def test_o2o_separation(self):
|
||||||
"OneToOne fields are constrained to a single database"
|
"OneToOne fields are constrained to a single database"
|
||||||
|
|
|
@ -83,7 +83,7 @@ class TestSaveLoad(TestCase):
|
||||||
instance = RangesModel(ints=None)
|
instance = RangesModel(ints=None)
|
||||||
instance.save()
|
instance.save()
|
||||||
loaded = RangesModel.objects.get()
|
loaded = RangesModel.objects.get()
|
||||||
self.assertEqual(None, loaded.ints)
|
self.assertIsNone(loaded.ints)
|
||||||
|
|
||||||
|
|
||||||
@skipUnlessPG92
|
@skipUnlessPG92
|
||||||
|
|
|
@ -7,7 +7,7 @@ from .models import ModelToValidate
|
||||||
class TestModelsWithValidators(ValidationTestCase):
|
class TestModelsWithValidators(ValidationTestCase):
|
||||||
def test_custom_validator_passes_for_correct_value(self):
|
def test_custom_validator_passes_for_correct_value(self):
|
||||||
mtv = ModelToValidate(number=10, name='Some Name', f_with_custom_validator=42)
|
mtv = ModelToValidate(number=10, name='Some Name', f_with_custom_validator=42)
|
||||||
self.assertEqual(None, mtv.full_clean())
|
self.assertIsNone(mtv.full_clean())
|
||||||
|
|
||||||
def test_custom_validator_raises_error_for_incorrect_value(self):
|
def test_custom_validator_raises_error_for_incorrect_value(self):
|
||||||
mtv = ModelToValidate(number=10, name='Some Name', f_with_custom_validator=12)
|
mtv = ModelToValidate(number=10, name='Some Name', f_with_custom_validator=12)
|
||||||
|
|
|
@ -19,7 +19,7 @@ class BaseModelValidationTests(ValidationTestCase):
|
||||||
|
|
||||||
def test_with_correct_value_model_validates(self):
|
def test_with_correct_value_model_validates(self):
|
||||||
mtv = ModelToValidate(number=10, name='Some Name')
|
mtv = ModelToValidate(number=10, name='Some Name')
|
||||||
self.assertEqual(None, mtv.full_clean())
|
self.assertIsNone(mtv.full_clean())
|
||||||
|
|
||||||
def test_custom_validate_method(self):
|
def test_custom_validate_method(self):
|
||||||
mtv = ModelToValidate(number=11)
|
mtv = ModelToValidate(number=11)
|
||||||
|
@ -37,7 +37,7 @@ class BaseModelValidationTests(ValidationTestCase):
|
||||||
def test_correct_FK_value_validates(self):
|
def test_correct_FK_value_validates(self):
|
||||||
parent = ModelToValidate.objects.create(number=10, name='Some Name')
|
parent = ModelToValidate.objects.create(number=10, name='Some Name')
|
||||||
mtv = ModelToValidate(number=10, name='Some Name', parent_id=parent.pk)
|
mtv = ModelToValidate(number=10, name='Some Name', parent_id=parent.pk)
|
||||||
self.assertEqual(None, mtv.full_clean())
|
self.assertIsNone(mtv.full_clean())
|
||||||
|
|
||||||
def test_limited_FK_raises_error(self):
|
def test_limited_FK_raises_error(self):
|
||||||
# The limit_choices_to on the parent field says that a parent object's
|
# The limit_choices_to on the parent field says that a parent object's
|
||||||
|
@ -52,7 +52,7 @@ class BaseModelValidationTests(ValidationTestCase):
|
||||||
|
|
||||||
def test_correct_email_value_passes(self):
|
def test_correct_email_value_passes(self):
|
||||||
mtv = ModelToValidate(number=10, name='Some Name', email='valid@email.com')
|
mtv = ModelToValidate(number=10, name='Some Name', email='valid@email.com')
|
||||||
self.assertEqual(None, mtv.full_clean())
|
self.assertIsNone(mtv.full_clean())
|
||||||
|
|
||||||
def test_wrong_url_value_raises_error(self):
|
def test_wrong_url_value_raises_error(self):
|
||||||
mtv = ModelToValidate(number=10, name='Some Name', url='not a url')
|
mtv = ModelToValidate(number=10, name='Some Name', url='not a url')
|
||||||
|
|
Loading…
Reference in New Issue