diff --git a/tests/regressiontests/serializers_regress/tests.py b/tests/regressiontests/serializers_regress/tests.py
index 704e34b..835caa3 100644
a
|
b
|
from django.db import connection, models
|
29 | 29 | from django.test import TestCase |
30 | 30 | from django.utils.functional import curry |
31 | 31 | from django.utils.unittest import skipUnless |
| 32 | from django.http import HttpResponse |
32 | 33 | |
33 | 34 | from .models import (BooleanData, CharData, DateData, DateTimeData, EmailData, |
34 | 35 | FileData, FilePathData, DecimalData, FloatData, IntegerData, IPAddressData, |
… |
… |
def streamTest(format, self):
|
469 | 470 | obj = ComplexModel(field1='first',field2='second',field3='third') |
470 | 471 | obj.save_base(raw=True) |
471 | 472 | |
472 | | # Serialize the test database to a stream |
473 | | stream = StringIO() |
474 | | serializers.serialize(format, [obj], indent=2, stream=stream) |
| 473 | for stream in (StringIO(), HttpResponse()): |
| 474 | # Serialize the test database to a stream |
| 475 | serializers.serialize(format, [obj], indent=2, stream=stream) |
475 | 476 | |
476 | | # Serialize normally for a comparison |
477 | | string_data = serializers.serialize(format, [obj], indent=2) |
| 477 | # Serialize normally for a comparison |
| 478 | string_data = serializers.serialize(format, [obj], indent=2) |
478 | 479 | |
479 | | # Check that the two are the same |
480 | | self.assertEqual(string_data, stream.getvalue()) |
481 | | stream.close() |
| 480 | # Check that the two are the same |
| 481 | if callable(getattr(stream, 'getvalue', None)): |
| 482 | self.assertEqual(string_data, stream.getvalue()) |
| 483 | elif callable(getattr(stream, 'content', None)): |
| 484 | self.assertEqual(string_data, stream.content()) |
| 485 | stream.close() |
482 | 486 | |
483 | 487 | for format in serializers.get_serializer_formats(): |
484 | 488 | setattr(SerializerTests, 'test_' + format + '_serializer', curry(serializerTest, format)) |