1
0
mirror of https://github.com/django/django.git synced 2025-10-26 07:06:08 +00:00

newforms-admin: Merged to trunk [5473].

git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@5475 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Joseph Kocherhans
2007-06-15 04:02:33 +00:00
parent ec622fc2a9
commit d304ccad8c
24 changed files with 465 additions and 79 deletions

View File

@@ -285,11 +285,11 @@ def fieldsTest(format, self):
obj = ComplexModel(field1='first',field2='second',field3='third')
obj.save()
# Serialize then deserialize the test database
serialized_data = serializers.serialize(format, [obj], indent=2, fields=('field1','field3'))
result = serializers.deserialize(format, serialized_data).next()
# Check that the deserialized object contains data in only the serialized fields.
self.assertEqual(result.object.field1, 'first')
self.assertEqual(result.object.field2, '')
@@ -301,19 +301,20 @@ def streamTest(format, self):
obj = ComplexModel(field1='first',field2='second',field3='third')
obj.save()
# Serialize the test database to a stream
stream = StringIO()
stream = StringIO()
serializers.serialize(format, [obj], indent=2, stream=stream)
# Serialize normally for a comparison
string_data = serializers.serialize(format, [obj], indent=2)
# Check that the two are the same
self.assertEqual(string_data, stream.buffer())
self.assertEqual(string_data, stream.getvalue())
stream.close()
for format in serializers.get_serializer_formats():
setattr(SerializerTests, 'test_'+format+'_serializer', curry(serializerTest, format))
setattr(SerializerTests, 'test_'+format+'_serializer_fields', curry(fieldsTest, format))
setattr(SerializerTests, 'test_'+format+'_serializer_stream', curry(fieldsTest, format))
if format != 'python':
setattr(SerializerTests, 'test_'+format+'_serializer_stream', curry(streamTest, format))