# Path: tests/compat.py
# class RequestFactory:
#     def method(self, method, url, params, body=None, root_path=None, **headers):
#     def get(self, url, params=None, **headers):
#     def post(self, url, params=None, **headers):


import pytest
from tri_struct import merged
from tri_form import Field, Form
from tri_form.compat import render_to_string, format_html, field_defaults_factory, render_template, Template
from .compat import RequestFactory, SafeText
    from django.db import models
    from django.db import models



def test_render_to_string():
    assert render_to_string(
        template_name='tri_form/non_editable.html',
        request=RequestFactory().get('/'),
        context=dict(
            field=dict(
                id=SafeText('<a b c><d><e>'),
                rendered_value=SafeText('<a b c><d><e>'),
            ),
        )
    ).strip() == '<span id="<a b c><d><e>"><a b c><d><e></span>'


def test_format_html():
    assert format_html('<{a}>{b}{c}', a='a', b=format_html('<b>'), c='<c>') == '<a><b>&lt;c&gt;'


def test_format_html2():
    assert render_template(RequestFactory().get('/'), Template('{{foo}}'), dict(foo=format_html('<a href="foo">foo</a>'))) == '<a href="foo">foo</a>'



# Path: tests/compat.py
# class RequestFactory:
#     def method(self, method, url, params, body=None, root_path=None, **headers):
#     def get(self, url, params=None, **headers):
#     def post(self, url, params=None, **headers):


# Path: tests/test_compat.py
import pytest
from tri_struct import merged
from tri_form import Field, Form
from tri_form.compat import render_to_string, format_html, field_defaults_factory, render_template, Template
from .compat import RequestFactory, SafeText
    from django.db import models
    from django.db import models




def test_render_to_string():
    assert render_to_string(
        template_name='tri_form/non_editable.html',
        request=RequestFactory().get('/'),
        context=dict(
            field=dict(
                id=SafeText('<a b c><d><e>'),
                rendered_value=SafeText('<a b c><d><e>'),
            ),
        )
    ).strip() == '<span id="<a b c><d><e>"><a b c><d><e></span>'


def test_format_html():
    assert format_html('<{a}>{b}{c}', a='a', b=format_html('<b>'), c='<c>') == '<a><b>&lt;c&gt;'


def test_format_html2():
    assert render_template(RequestFactory().get('/'), Template('{{foo}}'), dict(foo=format_html('<a href="foo">foo</a>'))) == '<a href="foo">foo</a>'



def test_format_html3():