diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-06-10 03:06:34 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-06-10 03:06:34 +0000 |
| commit | a33fb695e37c921d2bc0ffe3b011ad830f4bea56 (patch) | |
| tree | 9e5d0a23736cdc1a582855079561928bd3085497 | |
| parent | 1b02534ac343bc3b4b1a7703affe27f209a72bda (diff) | |
Fixed #4475 -- Fixed a problem that was preventing streaming tests for the
serializers from ever being run. Based on a patch from ian.g.kelly@gmail.com.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5453 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | AUTHORS | 1 | ||||
| -rw-r--r-- | tests/regressiontests/serializers_regress/tests.py | 17 |
2 files changed, 10 insertions, 8 deletions
@@ -130,6 +130,7 @@ answer newbie questions, and generally made Django that much better: junzhang.jn@gmail.com Antti Kaihola <http://akaihola.blogspot.com/> Ben Dean Kawamura <ben.dean.kawamura@gmail.com> + ian.g.kelly@gmail.com Garth Kidd <http://www.deadlybloodyserious.com/> kilian <kilian.cavalotti@lip6.fr> Sune Kirkeby <http://ibofobi.dk/> diff --git a/tests/regressiontests/serializers_regress/tests.py b/tests/regressiontests/serializers_regress/tests.py index cd27041eb2..1a144c8356 100644 --- a/tests/regressiontests/serializers_regress/tests.py +++ b/tests/regressiontests/serializers_regress/tests.py @@ -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)) |
