django-storages / storages / tests /

import os
import shutil

from django.test import TestCase
from django.core.files.base import ContentFile
from django.conf import settings

from storages.backends.hashpath import HashPathStorage

class HashPathStorageTest(TestCase):

    def setUp(self): = HashPathStorage()
        # make sure the profile upload folder exists
        if not os.path.exists(settings.MEDIA_ROOT):
    def tearDown(self):
        # remove uploaded profile picture
        if os.path.exists(settings.MEDIA_ROOT):

    def test_save_same_file(self):
        saves a file twice, the file should only be stored once, because the
        content/hash is the same
        path_1 ='test', ContentFile('new content'))
        path_2 ='test', ContentFile('new content'))

        self.assertEqual(path_1, path_2)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.