Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

24 lines (20 sloc) 0.88 kb
import os
from django.conf import settings
from django.test import TestCase
from autofixture import generators
class FilePathTests(TestCase):
def test_media_path_generator(self):
generate = generators.MediaFilePathGenerator(recursive=True)
for i in range(10):
path = generate()
self.assertTrue(len(path) > 0)
self.assertFalse(path.startswith('/'))
media_path = os.path.join(settings.MEDIA_ROOT, path)
self.assertTrue(os.path.exists(media_path))
self.assertTrue(os.path.isfile(media_path))
def test_media_path_generator_in_subdirectory(self):
generate = generators.MediaFilePathGenerator(path='textfiles')
for i in range(10):
path = generate()
self.assertTrue(path.startswith('textfiles/'))
self.assertTrue(path.endswith('.txt'))
Jump to Line
Something went wrong with that request. Please try again.