Ticket #16590: 16590.patch
File 16590.patch, 1.4 KB (added by , 13 years ago) |
---|
-
tests/regressiontests/file_storage/tests.py
542 542 size_1, size_2 = get_image_dimensions(image), get_image_dimensions(image) 543 543 self.assertEqual(image_pil.size, size_1) 544 544 self.assertEqual(size_1, size_2) 545 546 class ContentFileTestCase(unittest.TestCase): 547 """ 548 Test that the constructor of ContentFile accepts 'name' (#16590). 549 """ 550 def test_content_file_default_name(self): 551 self.assertEqual(ContentFile("content").name, None) 552 553 def test_content_file_custome_name(self): 554 name = "I can have a name too!" 555 self.assertEqual(ContentFile("content", name=name).name, name) -
django/core/files/base.py
122 122 """ 123 123 A File-like object that takes just raw content, rather than an actual file. 124 124 """ 125 def __init__(self, content ):125 def __init__(self, content, name=None): 126 126 content = content or '' 127 super(ContentFile, self).__init__(StringIO(content) )127 super(ContentFile, self).__init__(StringIO(content), name=name) 128 128 self.size = len(content) 129 129 130 130 def __str__(self):