'Test _check_python_file_is_safe tests for proper use of Text() and
Html().'

@data({'python': textwrap.dedent('\n                                                                                msg    =    Text("Mixed    {span_start}text{span_end}").format(\n                                                                                                span_start=HTML("<span>"),\n                                                                                                span_end=HTML("</span>"),\n                                                                                )\n                                                                '), 'rule': None}, {'python': textwrap.dedent('\n                                                                                msg    =    "Mixed    {span_start}text{span_end}".format(\n                                                                                                span_start=HTML("<span>"),\n                                                                                                span_end=HTML("</span>"),\n                                                                                )\n                                                                '), 'rule': Rules.python_requires_html_or_text}, {'python': textwrap.dedent('\n                                                                                msg    =    "Mixed    {span_start}{text}{span_end}".format(\n                                                                                                span_start=HTML("<span>"),\n                                                                                                text=Text("This    should    still    break."),\n                                                                                                span_end=HTML("</span>"),\n                                                                                )\n                                                                '), 'rule': Rules.python_requires_html_or_text}, {'python': textwrap.dedent('\n                                                                                msg    =    Text("Mixed    {link_start}text{link_end}".format(\n                                                                                                link_start=HTML("<a    href=\'{}\'>").format(url),\n                                                                                                link_end=HTML("</a>"),\n                                                                                ))\n                                                                '), 'rule': [Rules.python_close_before_format, Rules.python_requires_html_or_text]}, {'python': textwrap.dedent('\n                                                                                msg    =    Text("Mixed    {link_start}text{link_end}").format(\n                                                                                                link_start=HTML("<a    href=\'{}\'>".format(url)),\n                                                                                                link_end=HTML("</a>"),\n                                                                                )\n                                                                '), 'rule': Rules.python_close_before_format}, {'python': textwrap.dedent('\n                                                                                msg    =    Text("Mixed    {link_start}text{link_end}".format(\n                                                                                                link_start=HTML("<a    href=\'{}\'>".format(HTML(\'<b>\'))),\n                                                                                                link_end=HTML("</a>"),\n                                                                                ))\n                                                                '), 'rule': [Rules.python_close_before_format, Rules.python_requires_html_or_text, Rules.python_close_before_format, Rules.python_requires_html_or_text]}, {'python': textwrap.dedent('\n                                                                                msg    =    "Mixed    {span_start}text{span_end}".format(\n                                                                                                span_start="<span>",\n                                                                                                span_end="</span>",\n                                                                                )\n                                                                '), 'rule': [Rules.python_wrap_html, Rules.python_wrap_html]}, {'python': textwrap.dedent('\n                                                                                msg    =    Text(_("String    with    multiple    lines    "\n                                                                                                "{link_start}unenroll{link_end}    "\n                                                                                                "and    final    line")).format(\n                                                                                                                link_start=HTML(\n                                                                                                                                \'<a    id="link__over_multiple_lines"    \'\n                                                                                                                                \'data-course-id="{course_id}"    \'\n                                                                                                                                \'href="#test-modal">\'\n                                                                                                                ).format(\n                                                                                                                                #    Line    comment    with    \'    to    throw    off    parser\n                                                                                                                                course_id=course_overview.id\n                                                                                                                ),\n                                                                                                                link_end=HTML(\'</a>\'),\n                                                                                )\n                                                                '), 'rule': None}, {'python': "msg    =    '<span></span>'", 'rule': None}, {'python': "msg    =    HTML('<span></span>')", 'rule': None}, {'python': 'msg    =    \'<a    href="{}"\'.format(url)', 'rule': Rules.python_wrap_html}, {'python': "msg    =    '{}</p>'.format(message)", 'rule': Rules.python_wrap_html}, {'python': "r'regex    with    {}    and    named    group(?P<id>\\d+)?$'.format(test)", 'rule': None}, {'python': 'msg    =    \'<a    href="%s"\'    %    url', 'rule': Rules.python_interpolate_html}, {'python': textwrap.dedent("\n                                                                                def    __repr__(self):\n                                                                                                #    Assume    repr    implementations    are    safe,    and    not    HTML\n                                                                                                return    '<CCXCon    {}>'.format(self.title)\n                                                                "), 'rule': None}, {'python': "msg    =    '%s</p>'    %    message", 'rule': Rules.python_interpolate_html}, {'python': "msg    =    HTML('<span></span>'", 'rule': Rules.python_parse_error})
def test_check_python_with_text_and_html(self, data):

    linter = PythonLinter()
    results = FileResults('')
    file_content = textwrap.dedent(data['python'])
    linter.check_python_file_is_safe(file_content, results)
    self._validate_data_rules(data, results)
