From e8ee71e9a2cf2520cee0a14149679bae5355b263 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Tue, 27 Aug 2019 21:04:21 -0700 Subject: [PATCH] restore-backup, test_docs: Import settings from django.conf. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A settings module isn’t supposed to be imported directly. Signed-off-by: Anders Kaseorg --- scripts/setup/restore-backup | 5 +++-- zerver/tests/test_docs.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/setup/restore-backup b/scripts/setup/restore-backup index c2c66d7dfe..ada0357a6c 100755 --- a/scripts/setup/restore-backup +++ b/scripts/setup/restore-backup @@ -28,7 +28,7 @@ def restore_backup(tarball_file): # First, we unpack the /etc/zulip configuration, so we know how # this server is supposed to be configured (and can import - # /etc/zulip/settings.py via `from zproject import settings`, + # /etc/zulip/settings.py via `from django.conf import settings`, # next). Ignore errors if zulip-backup/settings is not present # (E.g. because this is a development backup). tarball_file.seek(0, 0) @@ -44,7 +44,8 @@ def restore_backup(tarball_file): stdin=tarball_file, ) - from zproject import settings + os.environ["DJANGO_SETTINGS_MODULE"] = "zproject.settings" + from django.conf import settings paths = [ ("settings", "/etc/zulip"), diff --git a/zerver/tests/test_docs.py b/zerver/tests/test_docs.py index 5de2d8da2f..1819fd0e25 100644 --- a/zerver/tests/test_docs.py +++ b/zerver/tests/test_docs.py @@ -4,11 +4,11 @@ import os import subprocess import ujson +from django.conf import settings from django.test import TestCase, override_settings from django.http import HttpResponse from typing import Any, Dict, List -from zproject.settings import DEPLOY_ROOT from zerver.lib.integrations import INTEGRATIONS from zerver.lib.storage import static_path from zerver.lib.test_classes import ZulipTestCase @@ -272,7 +272,7 @@ class HelpTest(ZulipTestCase): class IntegrationTest(TestCase): def test_check_if_every_integration_has_logo_that_exists(self) -> None: for integration in INTEGRATIONS.values(): - self.assertTrue(os.path.isfile(DEPLOY_ROOT + integration.logo_url), integration.name) + self.assertTrue(os.path.isfile(settings.DEPLOY_ROOT + integration.logo_url), integration.name) def test_api_url_view_subdomains_base(self) -> None: context = dict() # type: Dict[str, Any]