Ticket #10541: test.diff

File test.diff, 1.1 KB (added by Jonas H., 13 years ago)

Test case that demonstrates the issue

  • tests/regressiontests/file_storage/tests.py

    diff --git a/tests/regressiontests/file_storage/tests.py b/tests/regressiontests/file_storage/tests.py
    index 6a7a46a..fc761b6 100644
    a b except ImportError:  
    1818
    1919from django.conf import settings
    2020from django.core.exceptions import SuspiciousOperation, ImproperlyConfigured
    21 from django.core.files.base import ContentFile
     21from django.core.files.base import File, ContentFile
    2222from django.core.files.images import get_image_dimensions
    2323from django.core.files.storage import FileSystemStorage, get_storage_class
    2424from django.core.files.uploadedfile import UploadedFile
    class FileStorageTests(unittest.TestCase):  
    356356        finally:
    357357            os.remove = real_remove
    358358
     359    def test_save_from_pipe(self):
     360        from subprocess import Popen, PIPE
     361        proc = Popen(['echo', '1'], stdout=PIPE)
     362        proc.wait()
     363        self.storage.save('blah', File(proc.stdout))
     364        self.assertEqual(self.storage.open('blah').read(), '1\n')
     365
    359366
    360367class CustomStorage(FileSystemStorage):
    361368    def get_available_name(self, name):
Back to Top