summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Morozov <inductor2000@mail.ru>2015-11-20 23:59:34 +0300
committerClaude Paroz <claude@2xlibre.net>2015-11-22 20:32:14 +0100
commit6ca163d7cc451fafd3015fa2ee735d5377fa3065 (patch)
treef27e139dce046ff1d0ed59662a7793c94e60d88d
parent550107ff756beeb17b465e98c26c59e3dcc5eb3e (diff)
Fixed #25784 -- Prevented an exception on collectstatic help
Made the `manage.py help collectstatic` don't fail if the `STATIC_ROOT` setting is empty.
-rw-r--r--django/contrib/staticfiles/management/commands/collectstatic.py9
-rw-r--r--tests/staticfiles_tests/test_management.py14
2 files changed, 20 insertions, 3 deletions
diff --git a/django/contrib/staticfiles/management/commands/collectstatic.py b/django/contrib/staticfiles/management/commands/collectstatic.py
index e6b6198952..66dd782936 100644
--- a/django/contrib/staticfiles/management/commands/collectstatic.py
+++ b/django/contrib/staticfiles/management/commands/collectstatic.py
@@ -9,6 +9,7 @@ from django.core.files.storage import FileSystemStorage
from django.core.management.base import BaseCommand, CommandError
from django.core.management.color import no_style
from django.utils.encoding import smart_text
+from django.utils.functional import cached_property
from django.utils.six.moves import input
@@ -28,12 +29,14 @@ class Command(BaseCommand):
self.post_processed_files = []
self.storage = staticfiles_storage
self.style = no_style()
+
+ @cached_property
+ def local(self):
try:
self.storage.path('')
except NotImplementedError:
- self.local = False
- else:
- self.local = True
+ return False
+ return True
def add_arguments(self, parser):
parser.add_argument('--noinput', '--no-input',
diff --git a/tests/staticfiles_tests/test_management.py b/tests/staticfiles_tests/test_management.py
index 94166f9888..7c1c4223d0 100644
--- a/tests/staticfiles_tests/test_management.py
+++ b/tests/staticfiles_tests/test_management.py
@@ -6,6 +6,8 @@ import shutil
import tempfile
import unittest
+from admin_scripts.tests import AdminScriptTestCase
+
from django.conf import settings
from django.contrib.staticfiles import storage
from django.contrib.staticfiles.management.commands import collectstatic
@@ -130,6 +132,18 @@ class TestConfiguration(StaticFilesTestCase):
storage.staticfiles_storage = staticfiles_storage
+class TestCollectionHelpSubcommand(AdminScriptTestCase):
+ @override_settings(STATIC_ROOT=None)
+ def test_missing_settings_dont_prevent_help(self):
+ """
+ Even if the STATIC_ROOT setting is not set, one can still call the
+ `manage.py help collectstatic` command.
+ """
+ self.write_settings('settings.py', apps=['django.contrib.staticfiles'])
+ out, err = self.run_manage(['help', 'collectstatic'])
+ self.assertNoOutput(err)
+
+
class TestCollection(CollectionTestCase, TestDefaults):
"""
Test ``collectstatic`` management command.