Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed existing tests to handle BadSerializer.

When a BadSerializer instance is stubbed in for the yaml serializer,
make sure tests do not fail.
  • Loading branch information...
commit 9587d4eea09bc8d8a852dfb24c2a9227c74fd8ad 1 parent 0ac5e8d
@rca rca authored
Showing with 7 additions and 7 deletions.
  1. +1 −1  tests/serializers_regress/tests.py
  2. +6 −6 tests/timezones/tests.py
View
2  tests/serializers_regress/tests.py
@@ -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))
View
12 tests/timezones/tests.py
@@ -599,7 +599,7 @@ def test_naive_datetime(self):
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 @@ def test_naive_datetime_with_microsecond(self):
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 @@ def test_aware_datetime_with_microsecond(self):
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 @@ def test_aware_datetime_in_utc(self):
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 @@ def test_aware_datetime_in_local_timezone(self):
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 @@ def test_aware_datetime_in_other_timezone(self):
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
Please sign in to comment.
Something went wrong with that request. Please try again.