From 04469a4e8e116389ab912409becdccd7b5226a8a Mon Sep 17 00:00:00 2001 From: Calen Pennington <calen.pennington@gmail.com> Date: Mon, 16 Jul 2012 12:04:50 -0400 Subject: [PATCH] Strip out STATICFILES_DIRS that aren't in the mitx repo when running unit tests --- lms/envs/test.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lms/envs/test.py b/lms/envs/test.py index 870bc5a7ecf..a0a47690267 100644 --- a/lms/envs/test.py +++ b/lms/envs/test.py @@ -84,6 +84,21 @@ DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage' MEDIA_ROOT = TEST_ROOT / "uploads" MEDIA_URL = "/static/uploads/" STATICFILES_DIRS.append(("uploads", MEDIA_ROOT)) + +new_staticfiles_dirs = [] +# Strip out any static files that aren't in the repository root +# so that the tests can run with only the mitx directory checked out +for static_dir in STATICFILES_DIRS: + # Handle both tuples and non-tuple directory definitions + try: + _, data_dir = static_dir + except ValueError: + data_dir = static_dir + + if not data_dir.startswith(REPO_ROOT): + new_staticfiles_dirs.append(static_dir) +STATICFILES_DIRS = new_staticfiles_dirs + FILE_UPLOAD_TEMP_DIR = PROJECT_ROOT / "uploads" FILE_UPLOAD_HANDLERS = ( 'django.core.files.uploadhandler.MemoryFileUploadHandler', -- GitLab