Assert that two HTML snippets are semantically the same. Whitespace in most cases is ignored, and attribute ordering is not significant. The arguments must be valid HTML.
(self, html1, html2, msg=None)
| 953 | self.assertIsInstance(fieldclass(*field_args, **field_kwargs), fieldclass) |
| 954 | |
| 955 | def assertHTMLEqual(self, html1, html2, msg=None): |
| 956 | """ |
| 957 | Assert that two HTML snippets are semantically the same. |
| 958 | Whitespace in most cases is ignored, and attribute ordering is not |
| 959 | significant. The arguments must be valid HTML. |
| 960 | """ |
| 961 | dom1 = assert_and_parse_html( |
| 962 | self, html1, msg, "First argument is not valid HTML:" |
| 963 | ) |
| 964 | dom2 = assert_and_parse_html( |
| 965 | self, html2, msg, "Second argument is not valid HTML:" |
| 966 | ) |
| 967 | |
| 968 | if dom1 != dom2: |
| 969 | standardMsg = "%s != %s" % (safe_repr(dom1, True), safe_repr(dom2, True)) |
| 970 | diff = "\n" + "\n".join( |
| 971 | difflib.ndiff( |
| 972 | str(dom1).splitlines(), |
| 973 | str(dom2).splitlines(), |
| 974 | ) |
| 975 | ) |
| 976 | standardMsg = self._truncateMessage(standardMsg, diff) |
| 977 | self.fail(self._formatMessage(msg, standardMsg)) |
| 978 | |
| 979 | def assertHTMLNotEqual(self, html1, html2, msg=None): |
| 980 | """Assert that two HTML snippets are not semantically equivalent.""" |
no test coverage detected