Fixed issue with removing non-existent test media directory

pull/94/head
Piero Toffanin 2017-02-07 14:42:17 -05:00
rodzic 6d42de9cfd
commit 84c0d449be
1 zmienionych plików z 4 dodań i 4 usunięć

Wyświetl plik

@ -29,8 +29,9 @@ class TestApiTask(BootTransactionTestCase):
# This points to the test directory, but just in case # This points to the test directory, but just in case
# we double check that the directory is indeed a test directory # we double check that the directory is indeed a test directory
if "_test" in settings.MEDIA_ROOT: if "_test" in settings.MEDIA_ROOT:
logger.info("Cleaning up {}".format(settings.MEDIA_ROOT)) if os.path.exists(settings.MEDIA_ROOT):
shutil.rmtree(settings.MEDIA_ROOT) logger.info("Cleaning up {}".format(settings.MEDIA_ROOT))
shutil.rmtree(settings.MEDIA_ROOT)
else: else:
logger.warning("We did not remove MEDIA_ROOT because we couldn't find a _test suffix in its path.") logger.warning("We did not remove MEDIA_ROOT because we couldn't find a _test suffix in its path.")
@ -242,8 +243,7 @@ class TestApiTask(BootTransactionTestCase):
self.assertFalse(Task.objects.filter(pk=task.id).exists()) self.assertFalse(Task.objects.filter(pk=task.id).exists())
self.assertFalse(ImageUpload.objects.filter(task=task).exists()) self.assertFalse(ImageUpload.objects.filter(task=task).exists())
task_assets_path = os.path.join(settings.MEDIA_ROOT, task_assets_path = os.path.join(settings.MEDIA_ROOT, task_directory_path(task.id, task.project.id))
task_directory_path(task.id, task.project.id))
self.assertFalse(os.path.exists(task_assets_path)) self.assertFalse(os.path.exists(task_assets_path))
testWatch.clear() testWatch.clear()