from django.forms import NullBooleanSelect
from django.utils import translation
from .base import WidgetTest
class NullBooleanSelectTest(WidgetTest):
widget = NullBooleanSelect()
def test_render_true(self):
self.check_html(self.widget, 'is_cool', True, html=(
""""""
))
def test_render_false(self):
self.check_html(self.widget, 'is_cool', False, html=(
""""""
))
def test_render_none(self):
self.check_html(self.widget, 'is_cool', None, html=(
""""""
))
def test_render_value_unknown(self):
self.check_html(self.widget, 'is_cool', 'unknown', html=(
""""""
))
def test_render_value_true(self):
self.check_html(self.widget, 'is_cool', 'true', html=(
""""""
))
def test_render_value_false(self):
self.check_html(self.widget, 'is_cool', 'false', html=(
""""""
))
def test_render_value_1(self):
self.check_html(self.widget, 'is_cool', '1', html=(
""""""
))
def test_render_value_2(self):
self.check_html(self.widget, 'is_cool', '2', html=(
""""""
))
def test_render_value_3(self):
self.check_html(self.widget, 'is_cool', '3', html=(
""""""
))
def test_l10n(self):
"""
The NullBooleanSelect widget's options are lazily localized (#17190).
"""
widget = NullBooleanSelect()
with translation.override('de-at'):
self.check_html(widget, 'id_bool', True, html=(
"""
"""
))