'Test _check_python_file_is_safe tests for proper use of Text() and
Html() for a Python file with a mix of rules.'

def test_check_python_with_text_and_html_mixed(self):

    linter = PythonLinter()
    results = FileResults('')
    file_content = textwrap.dedent('\n                                                msg1    =    \'<a    href="{}"\'.format(url)\n                                                msg2    =    "Mixed    {link_start}text{link_end}".format(\n                                                                link_start=HTML("<a    href=\'{}\'>".format(url)),\n                                                                link_end="</a>",\n                                                )\n                                                msg3    =    \'<a    href="%s"\'    %    url\n                                ')
    linter.check_python_file_is_safe(file_content, results)
    results.violations.sort(key=(lambda violation: violation.sort_key()))
    self.assertEqual(len(results.violations), 5)
    self.assertEqual(results.violations[0].rule, Rules.python_wrap_html)
    self.assertEqual(results.violations[1].rule, Rules.python_requires_html_or_text)
    self.assertEqual(results.violations[2].rule, Rules.python_close_before_format)
    self.assertEqual(results.violations[3].rule, Rules.python_wrap_html)
    self.assertEqual(results.violations[4].rule, Rules.python_interpolate_html)
