mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Fixed #34343 -- Moved built-in templates to filesystem.
This commit is contained in:
committed by
Mariusz Felisiak
parent
bae053d497
commit
8eef22dfed
@@ -1,3 +1,5 @@
|
||||
from unittest import mock
|
||||
|
||||
from django.template import TemplateDoesNotExist
|
||||
from django.test import Client, RequestFactory, SimpleTestCase, override_settings
|
||||
from django.utils.translation import override
|
||||
@@ -117,3 +119,15 @@ class CsrfViewTests(SimpleTestCase):
|
||||
request = factory.post("/")
|
||||
with self.assertRaises(TemplateDoesNotExist):
|
||||
csrf_failure(request, template_name="nonexistent.html")
|
||||
|
||||
def test_template_encoding(self):
|
||||
"""
|
||||
The template is loaded directly, not via a template loader, and should
|
||||
be opened as utf-8 charset as is the default specified on template
|
||||
engines.
|
||||
"""
|
||||
from django.views.csrf import Path
|
||||
|
||||
with mock.patch.object(Path, "open") as m:
|
||||
csrf_failure(mock.MagicMock(), mock.Mock())
|
||||
m.assert_called_once_with(encoding="utf-8")
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import gettext
|
||||
import json
|
||||
from os import path
|
||||
from unittest import mock
|
||||
|
||||
from django.conf import settings
|
||||
from django.test import (
|
||||
@@ -507,6 +508,20 @@ class I18NViewTests(SimpleTestCase):
|
||||
with self.assertRaisesMessage(ValueError, msg):
|
||||
view(request, packages="unknown_package+unknown_package2")
|
||||
|
||||
def test_template_encoding(self):
|
||||
"""
|
||||
The template is loaded directly, not via a template loader, and should
|
||||
be opened as utf-8 charset as is the default specified on template
|
||||
engines.
|
||||
"""
|
||||
from django.views.i18n import Path
|
||||
|
||||
view = JavaScriptCatalog.as_view()
|
||||
request = RequestFactory().get("/")
|
||||
with mock.patch.object(Path, "open") as m:
|
||||
view(request)
|
||||
m.assert_called_once_with(encoding="utf-8")
|
||||
|
||||
|
||||
@override_settings(ROOT_URLCONF="view_tests.urls")
|
||||
class I18nSeleniumTests(SeleniumTestCase):
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import mimetypes
|
||||
import unittest
|
||||
from os import path
|
||||
from unittest import mock
|
||||
from urllib.parse import quote
|
||||
|
||||
from django.conf.urls.static import static
|
||||
@@ -8,7 +9,7 @@ from django.core.exceptions import ImproperlyConfigured
|
||||
from django.http import FileResponse, HttpResponseNotModified
|
||||
from django.test import SimpleTestCase, override_settings
|
||||
from django.utils.http import http_date
|
||||
from django.views.static import was_modified_since
|
||||
from django.views.static import directory_index, was_modified_since
|
||||
|
||||
from .. import urls
|
||||
from ..urls import media_dir
|
||||
@@ -152,6 +153,18 @@ class StaticTests(SimpleTestCase):
|
||||
response = self.client.get("/%s/" % self.prefix)
|
||||
self.assertEqual(response.content, b"Test index")
|
||||
|
||||
def test_template_encoding(self):
|
||||
"""
|
||||
The template is loaded directly, not via a template loader, and should
|
||||
be opened as utf-8 charset as is the default specified on template
|
||||
engines.
|
||||
"""
|
||||
from django.views.static import Path
|
||||
|
||||
with mock.patch.object(Path, "open") as m:
|
||||
directory_index(mock.MagicMock(), mock.MagicMock())
|
||||
m.assert_called_once_with(encoding="utf-8")
|
||||
|
||||
|
||||
class StaticHelperTest(StaticTests):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user