Ticket #11739: 11739_with_test.diff

File 11739_with_test.diff, 1.3 KB (added by cody@…, 3 years ago)

Same as last patch but with a test

  • django/core/files/base.py

    diff --git a/django/core/files/base.py b/django/core/files/base.py
    index 6204d71..6a82f80 100644
    a b  
    11import os
    2 try:
    3     from cStringIO import StringIO
    4 except ImportError:
    5     from StringIO import StringIO
     2from StringIO import StringIO
    63
    74from django.utils.encoding import smart_str, smart_unicode
    85from django.core.files.utils import FileProxyMixin
  • tests/regressiontests/file_storage/tests.py

    diff --git a/tests/regressiontests/file_storage/tests.py b/tests/regressiontests/file_storage/tests.py
    index d4530bb..5864732 100644
    a b class InconsistentGetImageDimensionsBug(unittest.TestCase): 
    542542        size_1, size_2 = get_image_dimensions(image), get_image_dimensions(image)
    543543        self.assertEqual(image_pil.size, size_1)
    544544        self.assertEqual(size_1, size_2)
     545
     546class UnicodeContentFileBug(unittest.TestCase):
     547    """
     548    Tests that ContentFile instances can contain unicode (#11739)
     549    """
     550    def test_unicode(self):
     551        """
     552        ContentFile instances should be able to handle unicode.
     553        """
     554        snowman = u'☃'
     555        file = ContentFile(snowman)
     556        self.assertEqual(file.read(), snowman)
Back to Top