From bcdc483a13ec61f83aac4230ce262bd42e6b8fff Mon Sep 17 00:00:00 2001 From: Corentin Flr <10946971+cogk@users.noreply.github.com> Date: Thu, 15 Jun 2023 18:36:30 +0200 Subject: [PATCH] fix(test): Fix test_never_render to get path as string, exclude PYC files from static downloads This test code never actually tested the behaviour for two reasons: - first, the page had an error which meant that a 500 Error page was returned (because `path` is not a string) - second, every page contains the string "400" because it's contained in some of the icons.svg icons! I also found a minor related bug in static_page.py, allowing people to download PYC files (pycache) --- frappe/tests/test_website.py | 5 +++-- frappe/website/page_renderers/static_page.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/frappe/tests/test_website.py b/frappe/tests/test_website.py index 6c319fff0a..1031a46c80 100644 --- a/frappe/tests/test_website.py +++ b/frappe/tests/test_website.py @@ -340,8 +340,9 @@ class TestWebsite(FrappeTestCase): FILES_TO_SKIP = choices(list(WWW.glob("**/*.py*")), k=10) for suffix in FILES_TO_SKIP: - content = get_response_content(suffix.relative_to(WWW)) - self.assertIn("404", content) + path: str = suffix.relative_to(WWW).as_posix() + content = get_response_content(path) + self.assertIn("Not Found", content) def test_metatags(self): content = get_response_content("/_test/_test_metatags") diff --git a/frappe/website/page_renderers/static_page.py b/frappe/website/page_renderers/static_page.py index 04e58ff217..d6de2f2991 100644 --- a/frappe/website/page_renderers/static_page.py +++ b/frappe/website/page_renderers/static_page.py @@ -8,7 +8,7 @@ import frappe from frappe.website.page_renderers.base_renderer import BaseRenderer from frappe.website.utils import is_binary_file -UNSUPPORTED_STATIC_PAGE_TYPES = ("html", "md", "js", "xml", "css", "txt", "py", "json") +UNSUPPORTED_STATIC_PAGE_TYPES = ("html", "md", "js", "xml", "css", "txt", "py", "pyc", "json") class StaticPage(BaseRenderer):