# Path: silhouette/templatetags/silhouette_filters.py
# def to_html_attrs(attrs):
# def is_text_input(bound_field):
# def is_number_input(bound_field):
# def is_email_input(bound_field):
# def is_date_input(bound_field):
# def is_datetime_input(bound_field):
# def is_split_datetime_widget(bound_field):
# def is_time_input(bound_field):
# def is_url_input(bound_field):
# def is_password_input(bound_field):
# def is_hidden_input(bound_field):
# def is_multiple_hidden_input(bound_field):
# def is_file_input(bound_field):
# def is_clearable_file_input(bound_field):
# def is_textarea(bound_field):
# def is_checkbox_input(bound_field):
# def is_select(bound_field):
# def is_select_multiple(bound_field):
# def is_radio_select(bound_field):
# def is_checkbox_select_multiple(bound_field):
# def is_null_boolean_select(bound_field):
# def is_select_date_widget(bound_field):
# 
# Path: tests/mock/forms.py
# class MockForm(forms.Form):
# 
#     text_input = forms.CharField(widget=forms.TextInput)
#     email_input = forms.EmailField()
#     url_input = forms.URLField()
#     number_input = forms.IntegerField()
#     password_input = forms.CharField(widget=forms.PasswordInput)
#     checkbox_input = forms.BooleanField()
#     hidden_input = forms.CharField(widget=forms.HiddenInput)
#     multiple_hidden_input = forms.CharField(widget=forms.MultipleHiddenInput)
#     file_input = forms.FileField(widget=forms.FileInput)
#     clearable_file_input = forms.FileField()
#     textarea = forms.CharField(widget=forms.Textarea)
#     date_input = forms.DateField()
#     datetime_input = forms.DateTimeField()
#     time_input = forms.TimeField()
#     split_datetime_widget = forms.DateTimeField(widget=forms.SplitDateTimeWidget)
#     select = forms.ChoiceField((('option 1', 'Option 1'), ('option 2', 'Option 2')))
#     null_boolean_select = forms.NullBooleanField()
#     select_multiple = forms.ChoiceField((('option 1', 'Option 1'), ('option 2', 'Option 2')), widget=forms.SelectMultiple)
#     checkbox_select_multiple = forms.ChoiceField((('option 1', 'Option 1'), ('option 2', 'Option 2')), widget=forms.CheckboxSelectMultiple)
#     radio_select = forms.ChoiceField((('option 1', 'Option 1'), ('option 2', 'Option 2')), widget=forms.RadioSelect)
#     select_date_widget = forms.DateField(widget=SelectDateWidget)


import unittest
from collections import OrderedDict
from silhouette.templatetags import silhouette_filters
from tests.mock.forms import MockForm



class TestWidgetFilters(unittest.TestCase):

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

    def tearDown(self):
        self.form = None

    def assertAllTrue(self, list, func):
        if not all(func(item) for item in list):
            raise self.failureException("Some items weren't True: {}".format(filter(lambda item: not func(item), list)))

    def assertAllFalse(self, list, func):
        try:
            self.assertAllTrue(list, lambda item: not func(item))
        except self.failureException:
            raise self.failureException("Some items weren't False: {}".format(filter(func, list)))

    def assertWidgetFilterTruth(self, filter, fields):
        test_func = lambda field: filter(self.form[field])
        self.assertAllTrue(fields, test_func)
        self.assertAllFalse(set(self.form.fields) - set(fields), test_func)

    def test_is_text_input(self):

# Path: silhouette/templatetags/silhouette_filters.py
# def to_html_attrs(attrs):
# def is_text_input(bound_field):
# def is_number_input(bound_field):
# def is_email_input(bound_field):
# def is_date_input(bound_field):
# def is_datetime_input(bound_field):
# def is_split_datetime_widget(bound_field):
# def is_time_input(bound_field):
# def is_url_input(bound_field):
# def is_password_input(bound_field):
# def is_hidden_input(bound_field):
# def is_multiple_hidden_input(bound_field):
# def is_file_input(bound_field):
# def is_clearable_file_input(bound_field):
# def is_textarea(bound_field):
# def is_checkbox_input(bound_field):
# def is_select(bound_field):
# def is_select_multiple(bound_field):
# def is_radio_select(bound_field):
# def is_checkbox_select_multiple(bound_field):
# def is_null_boolean_select(bound_field):
# def is_select_date_widget(bound_field):
# 
# Path: tests/mock/forms.py
# class MockForm(forms.Form):
# 
#     text_input = forms.CharField(widget=forms.TextInput)
#     email_input = forms.EmailField()
#     url_input = forms.URLField()
#     number_input = forms.IntegerField()
#     password_input = forms.CharField(widget=forms.PasswordInput)
#     checkbox_input = forms.BooleanField()
#     hidden_input = forms.CharField(widget=forms.HiddenInput)
#     multiple_hidden_input = forms.CharField(widget=forms.MultipleHiddenInput)
#     file_input = forms.FileField(widget=forms.FileInput)
#     clearable_file_input = forms.FileField()
#     textarea = forms.CharField(widget=forms.Textarea)
#     date_input = forms.DateField()
#     datetime_input = forms.DateTimeField()
#     time_input = forms.TimeField()
#     split_datetime_widget = forms.DateTimeField(widget=forms.SplitDateTimeWidget)
#     select = forms.ChoiceField((('option 1', 'Option 1'), ('option 2', 'Option 2')))
#     null_boolean_select = forms.NullBooleanField()
#     select_multiple = forms.ChoiceField((('option 1', 'Option 1'), ('option 2', 'Option 2')), widget=forms.SelectMultiple)
#     checkbox_select_multiple = forms.ChoiceField((('option 1', 'Option 1'), ('option 2', 'Option 2')), widget=forms.CheckboxSelectMultiple)
#     radio_select = forms.ChoiceField((('option 1', 'Option 1'), ('option 2', 'Option 2')), widget=forms.RadioSelect)
#     select_date_widget = forms.DateField(widget=SelectDateWidget)


# Path: tests/test_filters.py
import unittest
from collections import OrderedDict
from silhouette.templatetags import silhouette_filters
from tests.mock.forms import MockForm




class TestWidgetFilters(unittest.TestCase):

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

    def tearDown(self):
        self.form = None

    def assertAllTrue(self, list, func):
        if not all(func(item) for item in list):
            raise self.failureException("Some items weren't True: {}".format(filter(lambda item: not func(item), list)))

    def assertAllFalse(self, list, func):
        try:
            self.assertAllTrue(list, lambda item: not func(item))
        except self.failureException:
            raise self.failureException("Some items weren't False: {}".format(filter(func, list)))

    def assertWidgetFilterTruth(self, filter, fields):
        test_func = lambda field: filter(self.form[field])
        self.assertAllTrue(fields, test_func)
        self.assertAllFalse(set(self.form.fields) - set(fields), test_func)

    def test_is_text_input(self):

        self.assertWidgetFilterTruth(silhouette_filters.is_text_input, {'text_input', 'email_input', 'url_input', 'number_input', 'password_input', 'date_input', 'datetime_input', 'time_input'})