mirror of
https://github.com/django/django.git
synced 2025-01-10 10:26:34 +00:00
[1.10.x] Fixed #26922 -- Fixed SimpleTestCase.assertHTMLEqual() crash on Python 3.5+.
Backport of d7a097265b
from master
This commit is contained in:
parent
2d1aeccacc
commit
b3f96b5f73
@ -66,7 +66,7 @@ def assert_and_parse_html(self, html, user_msg, msg):
|
|||||||
try:
|
try:
|
||||||
dom = parse_html(html)
|
dom = parse_html(html)
|
||||||
except HTMLParseError as e:
|
except HTMLParseError as e:
|
||||||
standardMsg = '%s\n%s' % (msg, e.msg)
|
standardMsg = '%s\n%s' % (msg, e)
|
||||||
self.fail(self._formatMessage(user_msg, standardMsg))
|
self.fail(self._formatMessage(user_msg, standardMsg))
|
||||||
return dom
|
return dom
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
@ -629,6 +630,15 @@ class HTMLEqualTests(SimpleTestCase):
|
|||||||
self.assertHTMLEqual('<p>', '')
|
self.assertHTMLEqual('<p>', '')
|
||||||
with self.assertRaises(AssertionError):
|
with self.assertRaises(AssertionError):
|
||||||
self.assertHTMLEqual('', '<p>')
|
self.assertHTMLEqual('', '<p>')
|
||||||
|
error_msg = (
|
||||||
|
"First argument is not valid HTML:\n"
|
||||||
|
"('Unexpected end tag `div` (Line 1, Column 6)', (1, 6))"
|
||||||
|
) if sys.version_info >= (3, 5) else (
|
||||||
|
"First argument is not valid HTML:\n"
|
||||||
|
"Unexpected end tag `div` (Line 1, Column 6), at line 1, column 7"
|
||||||
|
)
|
||||||
|
with self.assertRaisesMessage(AssertionError, error_msg):
|
||||||
|
self.assertHTMLEqual('< div></ div>', '<div></div>')
|
||||||
with self.assertRaises(HTMLParseError):
|
with self.assertRaises(HTMLParseError):
|
||||||
parse_html('</p>')
|
parse_html('</p>')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user