1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Refs #27795 -- Removed force_bytes() usage in utils/_os.py.

This commit is contained in:
Jon Dufresne
2018-09-25 08:27:36 -07:00
committed by Tim Graham
parent 9a0e0d966a
commit bb81c22d90
3 changed files with 8 additions and 16 deletions

View File

@@ -156,24 +156,17 @@ class FileSystemLoaderTests(SimpleTestCase):
def test_unicode_template_name(self):
with self.source_checker(['/dir1', '/dir2']) as check_sources:
# UTF-8 bytestrings are permitted.
check_sources(b'\xc3\x85ngstr\xc3\xb6m', ['/dir1/Ångström', '/dir2/Ångström'])
# Strings are permitted.
check_sources('Ångström', ['/dir1/Ångström', '/dir2/Ångström'])
def test_utf8_bytestring(self):
"""
Invalid UTF-8 encoding in bytestrings should raise a useful error
"""
engine = self.engine
loader = engine.template_loaders[0]
with self.assertRaises(UnicodeDecodeError):
list(loader.get_template_sources(b'\xc3\xc3'))
def test_bytestring(self):
loader = self.engine.template_loaders[0]
msg = "Can't mix strings and bytes in path components"
with self.assertRaisesMessage(TypeError, msg):
list(loader.get_template_sources(b'\xc3\x85ngstr\xc3\xb6m'))
def test_unicode_dir_name(self):
with self.source_checker([b'/Stra\xc3\x9fe']) as check_sources:
with self.source_checker(['/Straße']) as check_sources:
check_sources('Ångström', ['/Straße/Ångström'])
check_sources(b'\xc3\x85ngstr\xc3\xb6m', ['/Straße/Ångström'])
@unittest.skipUnless(
os.path.normcase('/TEST') == os.path.normpath('/test'),