mirror of https://github.com/django/django.git
Fixed existing tests to handle BadSerializer.
When a BadSerializer instance is stubbed in for the yaml serializer, make sure tests do not fail.
This commit is contained in:
parent
0ac5e8d8e9
commit
9587d4eea0
|
@ -523,7 +523,7 @@ def streamTest(format, self):
|
|||
else:
|
||||
self.assertEqual(string_data, stream.content.decode('utf-8'))
|
||||
|
||||
for format in serializers.get_serializer_formats():
|
||||
for format in filter(lambda x: not isinstance(serializers.get_serializer(x), serializers.BadSerializer), serializers.get_serializer_formats()):
|
||||
setattr(SerializerTests, 'test_' + format + '_serializer', curry(serializerTest, format))
|
||||
setattr(SerializerTests, 'test_' + format + '_natural_key_serializer', curry(naturalKeySerializerTest, format))
|
||||
setattr(SerializerTests, 'test_' + format + '_serializer_fields', curry(fieldsTest, format))
|
||||
|
|
|
@ -599,7 +599,7 @@ class SerializationTests(TestCase):
|
|||
obj = next(serializers.deserialize('xml', data)).object
|
||||
self.assertEqual(obj.dt, dt)
|
||||
|
||||
if 'yaml' in serializers.get_serializer_formats():
|
||||
if not isinstance(serializers.get_serializer('yaml'), serializers.BadSerializer):
|
||||
data = serializers.serialize('yaml', [Event(dt=dt)])
|
||||
self.assert_yaml_contains_datetime(data, "2011-09-01 13:20:30")
|
||||
obj = next(serializers.deserialize('yaml', data)).object
|
||||
|
@ -623,7 +623,7 @@ class SerializationTests(TestCase):
|
|||
obj = next(serializers.deserialize('xml', data)).object
|
||||
self.assertEqual(obj.dt, dt)
|
||||
|
||||
if 'yaml' in serializers.get_serializer_formats():
|
||||
if not isinstance(serializers.get_serializer('yaml'), serializers.BadSerializer):
|
||||
data = serializers.serialize('yaml', [Event(dt=dt)])
|
||||
self.assert_yaml_contains_datetime(data, "2011-09-01 13:20:30.405060")
|
||||
obj = next(serializers.deserialize('yaml', data)).object
|
||||
|
@ -647,7 +647,7 @@ class SerializationTests(TestCase):
|
|||
obj = next(serializers.deserialize('xml', data)).object
|
||||
self.assertEqual(obj.dt, dt)
|
||||
|
||||
if 'yaml' in serializers.get_serializer_formats():
|
||||
if not isinstance(serializers.get_serializer('yaml'), serializers.BadSerializer):
|
||||
data = serializers.serialize('yaml', [Event(dt=dt)])
|
||||
self.assert_yaml_contains_datetime(data, "2011-09-01 17:20:30.405060+07:00")
|
||||
obj = next(serializers.deserialize('yaml', data)).object
|
||||
|
@ -671,7 +671,7 @@ class SerializationTests(TestCase):
|
|||
obj = next(serializers.deserialize('xml', data)).object
|
||||
self.assertEqual(obj.dt, dt)
|
||||
|
||||
if 'yaml' in serializers.get_serializer_formats():
|
||||
if not isinstance(serializers.get_serializer('yaml'), serializers.BadSerializer):
|
||||
data = serializers.serialize('yaml', [Event(dt=dt)])
|
||||
self.assert_yaml_contains_datetime(data, "2011-09-01 10:20:30+00:00")
|
||||
obj = next(serializers.deserialize('yaml', data)).object
|
||||
|
@ -695,7 +695,7 @@ class SerializationTests(TestCase):
|
|||
obj = next(serializers.deserialize('xml', data)).object
|
||||
self.assertEqual(obj.dt, dt)
|
||||
|
||||
if 'yaml' in serializers.get_serializer_formats():
|
||||
if not isinstance(serializers.get_serializer('yaml'), serializers.BadSerializer):
|
||||
data = serializers.serialize('yaml', [Event(dt=dt)])
|
||||
self.assert_yaml_contains_datetime(data, "2011-09-01 13:20:30+03:00")
|
||||
obj = next(serializers.deserialize('yaml', data)).object
|
||||
|
@ -719,7 +719,7 @@ class SerializationTests(TestCase):
|
|||
obj = next(serializers.deserialize('xml', data)).object
|
||||
self.assertEqual(obj.dt, dt)
|
||||
|
||||
if 'yaml' in serializers.get_serializer_formats():
|
||||
if not isinstance(serializers.get_serializer('yaml'), serializers.BadSerializer):
|
||||
data = serializers.serialize('yaml', [Event(dt=dt)])
|
||||
self.assert_yaml_contains_datetime(data, "2011-09-01 17:20:30+07:00")
|
||||
obj = next(serializers.deserialize('yaml', data)).object
|
||||
|
|
Loading…
Reference in New Issue