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

Refs #34986 -- Fixed some test assertions for PyPy.

These failures were due to minor inconsistencies or implementation
differences between CPython and PyPy.
This commit is contained in:
Nick Pope
2023-11-21 15:11:58 +00:00
committed by Mariusz Felisiak
parent 051dbb5388
commit baf705f34a
5 changed files with 17 additions and 6 deletions

View File

@@ -22,6 +22,7 @@ from django.utils.encoding import (
)
from django.utils.functional import SimpleLazyObject
from django.utils.translation import gettext_lazy
from django.utils.version import PYPY
class TestEncodingUtils(SimpleTestCase):
@@ -43,9 +44,10 @@ class TestEncodingUtils(SimpleTestCase):
self.assertIs(type(force_str(s)), str)
def test_force_str_DjangoUnicodeDecodeError(self):
reason = "unexpected end of data" if PYPY else "invalid start byte"
msg = (
"'utf-8' codec can't decode byte 0xff in position 0: invalid "
"start byte. You passed in b'\\xff' (<class 'bytes'>)"
f"'utf-8' codec can't decode byte 0xff in position 0: {reason}. "
"You passed in b'\\xff' (<class 'bytes'>)"
)
with self.assertRaisesMessage(DjangoUnicodeDecodeError, msg):
force_str(b"\xff")