# Path: tests/test_forms.py
# def remove_csrf(html_code):
#     csrf_regex = r'<input[^>]+csrfmiddlewaretoken[^>]+>'
#     return re.sub(csrf_regex, '', html_code)


import json
import pytest
from bs4 import BeautifulSoup
from tri_struct import Struct, merged
from tests.test_forms import remove_csrf
from tri_form import INITIALS_FROM_GET, DISPATCH_PATH_SEPARATOR
from tri_form.views import create_object, edit_object, create_or_edit_object_redirect
    from tests.models import CreateOrEditObjectTest, get_saved_something, Foo, reset_saved_something
    from tests.models import UniqueConstraintTest
    from tests.models import get_saved_something, reset_saved_something, NamespaceFormsTest
    from tests.models import Bar, Foo
    from tests.models import Foo
    from tests.models import Foo
    from tests.models import Foo
    from tests.models import Baz
    from tests.models import Foo
    expected_html = f"""
<html>
    <head>Create foo</head>
    <body>
        <form action="" method="post"><input type="hidden" name="csrfmiddlewaretoken" value="vt93bLZuhPhOAMvMFcyIOOXHYU3PCY0csFyUusDbb22FErp1uefHKD4JbMaa1SFr"/>
            <div class="tablewrapper">
                <table class="formview" width="100%">
                    <tr class="required">
                        <td class="description_container">
                            <div class="formlabel"><label for="id_foo">Foo</label></div>
                            <div class="formdescr">foo_help_text</div>
                        </td>
                        <td>
                            <input type="text" value="" name="{prefix}foo" id="id_foo">
                        </td>
                    </tr>
                    <input type="hidden" name="-{name or ''}" value=""/>
                </table>
            </div>
            <div class="form_buttons clear">
                <div class="links">
                    &nbsp;
                    <input accesskey="s" class="button" {name_attr}type="submit" value="Create foo"></input>
                </div>
            </div>
        </form>
    </body>
</html>
    """
    actual = remove_csrf(BeautifulSoup(response.content, 'html.parser').prettify())

# Path: tests/test_forms.py
# def remove_csrf(html_code):
#     csrf_regex = r'<input[^>]+csrfmiddlewaretoken[^>]+>'
#     return re.sub(csrf_regex, '', html_code)


# Path: tests/test_views.py
import json
import pytest
from bs4 import BeautifulSoup
from tri_struct import Struct, merged
from tests.test_forms import remove_csrf
from tri_form import INITIALS_FROM_GET, DISPATCH_PATH_SEPARATOR
from tri_form.views import create_object, edit_object, create_or_edit_object_redirect
    from tests.models import CreateOrEditObjectTest, get_saved_something, Foo, reset_saved_something
    from tests.models import UniqueConstraintTest
    from tests.models import get_saved_something, reset_saved_something, NamespaceFormsTest
    from tests.models import Bar, Foo
    from tests.models import Foo
    from tests.models import Foo
    from tests.models import Foo
    from tests.models import Baz
    from tests.models import Foo

    expected_html = f"""
<html>
    <head>Create foo</head>
    <body>
        <form action="" method="post"><input type="hidden" name="csrfmiddlewaretoken" value="vt93bLZuhPhOAMvMFcyIOOXHYU3PCY0csFyUusDbb22FErp1uefHKD4JbMaa1SFr"/>
            <div class="tablewrapper">
                <table class="formview" width="100%">
                    <tr class="required">
                        <td class="description_container">
                            <div class="formlabel"><label for="id_foo">Foo</label></div>
                            <div class="formdescr">foo_help_text</div>
                        </td>
                        <td>
                            <input type="text" value="" name="{prefix}foo" id="id_foo">
                        </td>
                    </tr>
                    <input type="hidden" name="-{name or ''}" value=""/>
                </table>
            </div>
            <div class="form_buttons clear">
                <div class="links">
                    &nbsp;
                    <input accesskey="s" class="button" {name_attr}type="submit" value="Create foo"></input>
                </div>
            </div>
        </form>
    </body>
</html>
    """
    actual = remove_csrf(BeautifulSoup(response.content, 'html.parser').prettify())

    expected = remove_csrf(BeautifulSoup(expected_html, 'html.parser').prettify())