diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py b/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py index 8ed44a1f5e..e52af84d37 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py @@ -326,10 +326,12 @@ class TestMongoModuleStore(object): self.content_store.find(location) root_dir = path(mkdtemp()) - export_to_xml(self.store, self.content_store, course_location, root_dir, 'test_export') - assert_true(path(root_dir / 'test_export/static/images/course_image.jpg').isfile()) - assert_true(path(root_dir / 'test_export/static/images_course_image.jpg').isfile()) - shutil.rmtree(root_dir) + try: + export_to_xml(self.store, self.content_store, course_location, root_dir, 'test_export') + assert_true(path(root_dir / 'test_export/static/images/course_image.jpg').isfile()) + assert_true(path(root_dir / 'test_export/static/images_course_image.jpg').isfile()) + finally: + shutil.rmtree(root_dir) def test_export_course_image_nondefault(self): """ @@ -340,10 +342,12 @@ class TestMongoModuleStore(object): assert_true(course.course_image, 'just_a_test.jpg') root_dir = path(mkdtemp()) - export_to_xml(self.store, self.content_store, course.location, root_dir, 'test_export') - assert_true(path(root_dir / 'test_export/static/just_a_test.jpg').isfile()) - assert_false(path(root_dir / 'test_export/static/images/course_image.jpg').isfile()) - shutil.rmtree(root_dir) + try: + export_to_xml(self.store, self.content_store, course.location, root_dir, 'test_export') + assert_true(path(root_dir / 'test_export/static/just_a_test.jpg').isfile()) + assert_false(path(root_dir / 'test_export/static/images/course_image.jpg').isfile()) + finally: + shutil.rmtree(root_dir) def test_course_without_image(self): """ @@ -352,10 +356,12 @@ class TestMongoModuleStore(object): """ course = self.get_course_by_id('edX/simple_with_draft/2012_Fall') root_dir = path(mkdtemp()) - export_to_xml(self.store, self.content_store, course.location, root_dir, 'test_export') - assert_false(path(root_dir / 'test_export/static/images/course_image.jpg').isfile()) - assert_false(path(root_dir / 'test_export/static/images_course_image.jpg').isfile()) - shutil.rmtree(root_dir) + try: + export_to_xml(self.store, self.content_store, course.location, root_dir, 'test_export') + assert_false(path(root_dir / 'test_export/static/images/course_image.jpg').isfile()) + assert_false(path(root_dir / 'test_export/static/images_course_image.jpg').isfile()) + finally: + shutil.rmtree(root_dir) diff --git a/lms/djangoapps/courseware/courses.py b/lms/djangoapps/courseware/courses.py index 51192088fe..3937860f08 100644 --- a/lms/djangoapps/courseware/courses.py +++ b/lms/djangoapps/courseware/courses.py @@ -110,14 +110,15 @@ def course_image_url(course): # set different than the default, return that path so that # courses can use custom course image paths, otherwise just # return the default static path. + url = '/static/' + (course.static_asset_path or getattr(course, 'data_dir', '')) if hasattr(course, 'course_image') and course.course_image != course.fields['course_image'].default: - return '/static/' + (course.static_asset_path or getattr(course, 'data_dir', '')) + '/' + course.course_image + url += '/' + course.course_image else: - return '/static/' + (course.static_asset_path or getattr(course, 'data_dir', '')) + "/images/course_image.jpg" + url += '/images/course_image.jpg' else: loc = StaticContent.compute_location(course.location.org, course.location.course, course.course_image) - _path = StaticContent.get_url_path_from_location(loc) - return _path + url = StaticContent.get_url_path_from_location(loc) + return url def find_file(filesystem, dirs, filename):