Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
dev_urls: Give the user_avatars URLPattern a name.
Anders Kaseorgb41165fd0152
diff --git a/zerver/lib/test_runner.py b/zerver/lib/test_runner.pyindex cb621f884f4..96404293586 100644--- a/zerver/lib/test_runner.py+++ b/zerver/lib/test_runner.py@@ -13,7 +13,6 @@ from django.test import TestCasefrom django.test import runner as django_runnerfrom django.test.runner import DiscoverRunnerfrom django.test.signals import template_rendered-from django.urls.resolvers import URLPatternfrom scripts.lib.zulip_tools import (TEMPLATE_DATABASE_DIR,@@ -196,22 +195,10 @@ def init_worker(counter: Synchronized) -> None:create_test_databases(_worker_id)initialize_worker_path(_worker_id)- def is_upload_avatar_url(url: URLPattern) -> bool:- if url.pattern.regex.pattern == r'^user_avatars/(?P<path>.*)$':- return True- return False-# We manually update the upload directory path in the url regex.- from zproject import dev_urls- found = False- for url in dev_urls.urls:- if is_upload_avatar_url(url):- found = True- new_root = os.path.join(settings.LOCAL_UPLOADS_DIR, "avatars")- url.default_args['document_root'] = new_root-- if not found:- print("*** Upload directory not found.")+ from zproject.dev_urls import avatars_url+ new_root = os.path.join(settings.LOCAL_UPLOADS_DIR, "avatars")+ avatars_url.default_args['document_root'] = new_rootclass ParallelTestSuite(django_runner.ParallelTestSuite):run_subsuite = run_subsuitediff --git a/zproject/dev_urls.py b/zproject/dev_urls.pyindex 1c5253722ba..5f0ab9fbf00 100644--- a/zproject/dev_urls.py+++ b/zproject/dev_urls.py@@ -84,7 +84,9 @@ i18n_urls = [# On a production instance, these files would be served by nginx.if settings.LOCAL_UPLOADS_DIR is not None:- urls += [- re_path(r'^user_avatars/(?P<path>.*)$', serve,- {'document_root': os.path.join(settings.LOCAL_UPLOADS_DIR, "avatars")}),- ]+ avatars_url = re_path(+ r'^user_avatars/(?P<path>.*)$',+ serve,+ {'document_root': os.path.join(settings.LOCAL_UPLOADS_DIR, "avatars")},+ )+ urls += [avatars_url]