mirror of https://github.com/django/django.git
Fixed #27308 -- Fixed BytesWarnings in the test suite.
This commit is contained in:
parent
4696078832
commit
75f0070a54
|
@ -69,7 +69,7 @@ class MultiPartParser:
|
|||
ctypes, opts = parse_header(content_type.encode('ascii'))
|
||||
boundary = opts.get('boundary')
|
||||
if not boundary or not cgi.valid_boundary(boundary):
|
||||
raise MultiPartParserError('Invalid boundary in multipart: %s' % boundary)
|
||||
raise MultiPartParserError('Invalid boundary in multipart: %s' % boundary.decode())
|
||||
|
||||
# Content-Length should contain the length of the body we are about
|
||||
# to receive.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from django.forms import ChoiceField, Form, ValidationError
|
||||
from django.test import SimpleTestCase, ignore_warnings
|
||||
from django.test import SimpleTestCase
|
||||
|
||||
from . import FormFieldAssertionsMixin
|
||||
|
||||
|
@ -82,16 +82,3 @@ class ChoiceFieldTest(FormFieldAssertionsMixin, SimpleTestCase):
|
|||
'<select id="id_f" name="f" disabled><option value="J">John</option>'
|
||||
'<option value="P">Paul</option></select>'
|
||||
)
|
||||
|
||||
@ignore_warnings(category=UnicodeWarning)
|
||||
def test_utf8_bytesrings(self):
|
||||
# Choice validation with UTF-8 bytestrings as input (these are the
|
||||
# Russian abbreviations "мес." and "шт.".
|
||||
f = ChoiceField(
|
||||
choices=(
|
||||
(b'\xd0\xbc\xd0\xb5\xd1\x81.', b'\xd0\xbc\xd0\xb5\xd1\x81.'),
|
||||
(b'\xd1\x88\xd1\x82.', b'\xd1\x88\xd1\x82.'),
|
||||
),
|
||||
)
|
||||
self.assertEqual(f.clean('\u0448\u0442.'), '\u0448\u0442.')
|
||||
self.assertEqual(f.clean(b'\xd1\x88\xd1\x82.'), '\u0448\u0442.')
|
||||
|
|
|
@ -140,7 +140,7 @@ class DebugViewTests(LoggingCaptureMixin, SimpleTestCase):
|
|||
id_repr = match.group('id')
|
||||
self.assertFalse(
|
||||
re.search(b'[^c0-9]', id_repr),
|
||||
"Numeric IDs in debug response HTML page shouldn't be localized (value: %s)." % id_repr
|
||||
"Numeric IDs in debug response HTML page shouldn't be localized (value: %s)." % id_repr.decode()
|
||||
)
|
||||
|
||||
def test_template_exceptions(self):
|
||||
|
|
|
@ -64,8 +64,8 @@ class DefaultsTests(TestCase):
|
|||
# See ticket #14565
|
||||
for url in self.nonexistent_urls:
|
||||
response = self.client.get(url)
|
||||
self.assertNotEqual(response.content, 'NOTPROVIDED')
|
||||
self.assertNotEqual(response.content, '')
|
||||
self.assertNotEqual(response.content, b'NOTPROVIDED')
|
||||
self.assertNotEqual(response.content, b'')
|
||||
|
||||
def test_server_error(self):
|
||||
"The server_error view raises a 500 status"
|
||||
|
|
Loading…
Reference in New Issue