Ticket #26896: 0001-Test-for-reverse_lazy.patch

File 0001-Test-for-reverse_lazy.patch, 1.5 KB (added by tpazderka, 8 years ago)

Patch for tests/file_storage/tests.py

  • tests/file_storage/tests.py

    From d4e4af008a2f0968a3afd9a628faa6b849cce499 Mon Sep 17 00:00:00 2001
    From: Tomas Pazderka <tomas.pazderka@nic.cz>
    Date: Mon, 18 Jul 2016 13:54:31 +0200
    Subject: [PATCH] Test for reverse_lazy
    
    ---
     tests/file_storage/tests.py | 14 ++++++++++++++
     1 file changed, 14 insertions(+)
    
    diff --git a/tests/file_storage/tests.py b/tests/file_storage/tests.py
    index b489c02..9dd4e57 100644
    a b from django.core.files.storage import FileSystemStorage, get_storage_class  
    1919from django.core.files.uploadedfile import (
    2020    InMemoryUploadedFile, SimpleUploadedFile, TemporaryUploadedFile,
    2121)
     22from django.core.urlresolvers import NoReverseMatch, reverse_lazy
    2223from django.test import (
    2324    LiveServerTestCase, SimpleTestCase, TestCase, override_settings,
    2425)
    class FileStorageTests(unittest.TestCase):  
    9899        shutil.rmtree(self.temp_dir)
    99100        shutil.rmtree(self.temp_dir2)
    100101
     102    def test_lazy_init(self):
     103        """
     104        Makes sure that init is lazy.
     105        """
     106        storage = self.storage_class(location=self.temp_dir,
     107            base_url=reverse_lazy('app:url'))
     108        f = ContentFile('custom contents')
     109        f.name = 'test.file'
     110        storage.save(None, f)
     111
     112        with self.assertRaises(NoReverseMatch):
     113            storage.url(f.name)
     114
    101115    def test_empty_location(self):
    102116        """
    103117        Makes sure an exception is raised if the location is empty
Back to Top