Loading django/core/serializers/json.py +2 −3 Original line number Diff line number Diff line Loading @@ -52,9 +52,8 @@ class Serializer(PythonSerializer): self._current = None def getvalue(self): # overwrite PythonSerializer.getvalue() with base Serializer.getvalue() if callable(getattr(self.stream, 'getvalue', None)): return self.stream.getvalue() # Grand-parent super return super(PythonSerializer, self).getvalue() def Deserializer(stream_or_string, **options): Loading django/core/serializers/pyyaml.py +2 −1 Original line number Diff line number Diff line Loading @@ -44,7 +44,8 @@ class Serializer(PythonSerializer): yaml.dump(self.objects, self.stream, Dumper=DjangoSafeDumper, **self.options) def getvalue(self): return self.stream.getvalue() # Grand-parent super return super(PythonSerializer, self).getvalue() def Deserializer(stream_or_string, **options): """ Loading tests/regressiontests/serializers_regress/tests.py +13 −9 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ from django.core import serializers from django.core.serializers import SerializerDoesNotExist from django.core.serializers.base import DeserializationError from django.db import connection, models from django.http import HttpResponse from django.test import TestCase from django.utils.functional import curry from django.utils.unittest import skipUnless Loading Loading @@ -501,14 +502,17 @@ def streamTest(format, self): obj.save_base(raw=True) # Serialize the test database to a stream stream = BytesIO() for stream in (BytesIO(), HttpResponse()): 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 if isinstance(stream, BytesIO): self.assertEqual(string_data, stream.getvalue()) else: self.assertEqual(string_data, stream.content) stream.close() for format in serializers.get_serializer_formats(): Loading Loading
django/core/serializers/json.py +2 −3 Original line number Diff line number Diff line Loading @@ -52,9 +52,8 @@ class Serializer(PythonSerializer): self._current = None def getvalue(self): # overwrite PythonSerializer.getvalue() with base Serializer.getvalue() if callable(getattr(self.stream, 'getvalue', None)): return self.stream.getvalue() # Grand-parent super return super(PythonSerializer, self).getvalue() def Deserializer(stream_or_string, **options): Loading
django/core/serializers/pyyaml.py +2 −1 Original line number Diff line number Diff line Loading @@ -44,7 +44,8 @@ class Serializer(PythonSerializer): yaml.dump(self.objects, self.stream, Dumper=DjangoSafeDumper, **self.options) def getvalue(self): return self.stream.getvalue() # Grand-parent super return super(PythonSerializer, self).getvalue() def Deserializer(stream_or_string, **options): """ Loading
tests/regressiontests/serializers_regress/tests.py +13 −9 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ from django.core import serializers from django.core.serializers import SerializerDoesNotExist from django.core.serializers.base import DeserializationError from django.db import connection, models from django.http import HttpResponse from django.test import TestCase from django.utils.functional import curry from django.utils.unittest import skipUnless Loading Loading @@ -501,14 +502,17 @@ def streamTest(format, self): obj.save_base(raw=True) # Serialize the test database to a stream stream = BytesIO() for stream in (BytesIO(), HttpResponse()): 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 if isinstance(stream, BytesIO): self.assertEqual(string_data, stream.getvalue()) else: self.assertEqual(string_data, stream.content) stream.close() for format in serializers.get_serializer_formats(): Loading