From a1d296b802b99b34b700a722ffe9229c6f084e76 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Tue, 28 Feb 2017 21:42:31 -0800 Subject: [PATCH] report: Use DEVELOPMENT instead of DEBUG setting. This fixes a weird issue where the following sequences of tests would fail: test-backend zerver.tests.test_messages.PersonalMessagesTest.test_personal_to_self zerver.tests.test_report.TestReport.test_report_error zerver.tests.test_templates.TemplateTestCase.test_custom_tos_template It appears that all 3 tests are required for the failure. While it's not entirely clear what the cause is, a very likely factor is that settings.DEBUG is special, and so changing it at runtime is likely to cause weird problems like this. We fix this by replacing it with settings.DEVELOPMENT, which has the same value in all environments, but doesn't have this problem of being a special Django thing. --- zerver/tests/test_report.py | 4 ++-- zerver/views/report.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/zerver/tests/test_report.py b/zerver/tests/test_report.py index 8b9472f03f..4668c37699 100644 --- a/zerver/tests/test_report.py +++ b/zerver/tests/test_report.py @@ -145,10 +145,10 @@ class TestReport(ZulipTestCase): self.assert_json_success(result) # If js_source_map is present, then the stack trace should be annotated. - # DEBUG=False and TEST_SUITE=False are necessary to ensure that + # DEVELOPMENT=False and TEST_SUITE=False are necessary to ensure that # js_source_map actually gets instantiated. with \ - self.settings(DEBUG=False, TEST_SUITE=False), \ + self.settings(DEVELOPMENT=False, TEST_SUITE=False), \ mock.patch('zerver.lib.unminify.SourceMap.annotate_stacktrace') as annotate: result = self.client_post("/json/report_error", params) self.assert_json_success(result) diff --git a/zerver/views/report.py b/zerver/views/report.py index e196b1d189..f76b91e9d5 100644 --- a/zerver/views/report.py +++ b/zerver/views/report.py @@ -24,7 +24,7 @@ js_source_map = None def get_js_source_map(): # type: () -> Optional[SourceMap] global js_source_map - if not js_source_map and not (settings.DEBUG or settings.TEST_SUITE): + if not js_source_map and not (settings.DEVELOPMENT or settings.TEST_SUITE): js_source_map = SourceMap(os.path.join( settings.DEPLOY_ROOT, 'prod-static/source-map')) return js_source_map