# Path: tests/pods_utils.py
# def clear_app_settings_cache():
#     # Clean up. Django Pods caches settings once loaded. Remove cached settings
#     from silhouette.apps import Silhouette
#     if hasattr(Silhouette.settings, 'PATH'):
#         del Silhouette.settings.PATH
#     if hasattr(Silhouette.settings, 'THEME'):
#         del Silhouette.settings.THEME
#     if hasattr(Silhouette.settings, 'PATTERNS'):
#         del Silhouette.settings.PATTERNS
# 
# Path: tests/mock/forms.py
# class MockForm(forms.Form):
# class MockForm2(forms.Form):
# 
# Path: tests/mock/tags.py
# class MockTag(BaseSilhouette):
# 
#     def get_extra_context(self):
#         ctx = {"obj": self.obj}
#         # merge if any "cascaded_*" attributes in context
#         attrs = self.merge_attrs(self.cascaded_attrs('cascaded'), self.kwargs)
#         # cascade any "cascaded_*" attributes to sub contexts
#         attrs = self.build_attrs(attrs, 'cascaded')
#         ctx.update(attrs)
#         return ctx


from django.test import SimpleTestCase
from django.template.context import Context
    from django.template.base import TemplateDoesNotExist
    from django.template.exceptions import TemplateDoesNotExist
    from django.template.loader import get_template_from_string
    from django.template import engines
from django.test.utils import override_settings
from .pods_utils import clear_app_settings_cache
from .mock.forms import MockForm, MockFormSet
from .mock.tags import MockTag
        template_source = """{% load silhouette_tags %}{% form_errors form id="form-errors" template="does/not/exist.html" %}"""
        template_target = ""
        self.assertEqual(template_target, get_template_from_string(template_source).render(self.context).strip())

    def test_form_fields(self):
        template_source = """{% load silhouette_tags %}{% form_fields form class="form-fields" %}"""
        template_target = """<div class="form-fields"><!-- field 1 here --></div><div class="form-fields"><!-- field 2 here --></div>"""
        self.assertEqual(template_target, get_template_from_string(template_source).render(self.context).strip())

    def test_form_fields_missing_template(self):
        template_source = """{% load silhouette_tags %}{% form_fields form class="form-fields" template="does/not/exist.html" %}"""
        with self.assertRaises(TemplateDoesNotExist):
            get_template_from_string(template_source).render(self.context)

    def test_form_controls(self):
        template_source = """{% load silhouette_tags %}{% form_controls form class="form-controls" %}"""
        template_target = """<button type="submit" class="form-controls">Submit</button>"""
        self.assertEqual(template_target, get_template_from_string(template_source).render(self.context).strip())

    def test_form_controls_missing_template(self):
        template_source = """{% load silhouette_tags %}{% form_controls form class="form-controls" template="does/not/exist.html" %}"""
        template_target = ""
        self.assertEqual(template_target, get_template_from_string(template_source).render(self.context).strip())


@override_settings(SILHOUETTE_PATH="test_tags/formsets")
class TestFormsetTags(SimpleTestCase):

    def setUp(self):
        self.form = MockForm({})

# Path: tests/pods_utils.py
# def clear_app_settings_cache():
#     # Clean up. Django Pods caches settings once loaded. Remove cached settings
#     from silhouette.apps import Silhouette
#     if hasattr(Silhouette.settings, 'PATH'):
#         del Silhouette.settings.PATH
#     if hasattr(Silhouette.settings, 'THEME'):
#         del Silhouette.settings.THEME
#     if hasattr(Silhouette.settings, 'PATTERNS'):
#         del Silhouette.settings.PATTERNS
# 
# Path: tests/mock/forms.py
# class MockForm(forms.Form):
# class MockForm2(forms.Form):
# 
# Path: tests/mock/tags.py
# class MockTag(BaseSilhouette):
# 
#     def get_extra_context(self):
#         ctx = {"obj": self.obj}
#         # merge if any "cascaded_*" attributes in context
#         attrs = self.merge_attrs(self.cascaded_attrs('cascaded'), self.kwargs)
#         # cascade any "cascaded_*" attributes to sub contexts
#         attrs = self.build_attrs(attrs, 'cascaded')
#         ctx.update(attrs)
#         return ctx


# Path: tests/test_tags.py
from django.test import SimpleTestCase
from django.template.context import Context
    from django.template.base import TemplateDoesNotExist
    from django.template.exceptions import TemplateDoesNotExist
    from django.template.loader import get_template_from_string
    from django.template import engines
from django.test.utils import override_settings
from .pods_utils import clear_app_settings_cache
from .mock.forms import MockForm, MockFormSet
from .mock.tags import MockTag

        template_source = """{% load silhouette_tags %}{% form_errors form id="form-errors" template="does/not/exist.html" %}"""
        template_target = ""
        self.assertEqual(template_target, get_template_from_string(template_source).render(self.context).strip())

    def test_form_fields(self):
        template_source = """{% load silhouette_tags %}{% form_fields form class="form-fields" %}"""
        template_target = """<div class="form-fields"><!-- field 1 here --></div><div class="form-fields"><!-- field 2 here --></div>"""
        self.assertEqual(template_target, get_template_from_string(template_source).render(self.context).strip())

    def test_form_fields_missing_template(self):
        template_source = """{% load silhouette_tags %}{% form_fields form class="form-fields" template="does/not/exist.html" %}"""
        with self.assertRaises(TemplateDoesNotExist):
            get_template_from_string(template_source).render(self.context)

    def test_form_controls(self):
        template_source = """{% load silhouette_tags %}{% form_controls form class="form-controls" %}"""
        template_target = """<button type="submit" class="form-controls">Submit</button>"""
        self.assertEqual(template_target, get_template_from_string(template_source).render(self.context).strip())

    def test_form_controls_missing_template(self):
        template_source = """{% load silhouette_tags %}{% form_controls form class="form-controls" template="does/not/exist.html" %}"""
        template_target = ""
        self.assertEqual(template_target, get_template_from_string(template_source).render(self.context).strip())


@override_settings(SILHOUETTE_PATH="test_tags/formsets")
class TestFormsetTags(SimpleTestCase):

    def setUp(self):
        self.form = MockForm({})

        self.formset = MockFormSet(data={'form-TOTAL_FORMS': '2',