From 042fa5dba4ec4d9e737f9a7c5081dba756d8050e Mon Sep 17 00:00:00 2001 From: Greg Jurman Date: Mon, 12 Mar 2012 18:18:14 -0400 Subject: [PATCH] Fixed failure with checkbox --- tests/test_widgets.py | 16 ++++++++-------- tw2/forms/widgets.py | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/test_widgets.py b/tests/test_widgets.py index 261c8ee..6bcfbef 100644 --- a/tests/test_widgets.py +++ b/tests/test_widgets.py @@ -18,20 +18,20 @@ class TestInputField(WidgetTest): widget = InputField attrs = {'type':'foo', 'css_class':'something'} - params = {'value':6} - expected = '' + params = {'value':7} + expected = '' class TestTextField(WidgetTest): widget = TextField - attrs = {'css_class':'something', 'size':'60', 'placeholder': "Search..."} - params = {'value':6} + attrs = {'css_class':'something', 'size':'60'} + params = {'value':6, 'placeholder': "Search..."} expected = '' class TestTextArea(WidgetTest): widget = TextArea attrs = {'css_class':'something', 'rows':6, 'cols':10} - params = {'value':'6'} - expected = '' + params = {'value':'5'} + expected = '' class TestCheckbox(WidgetTest): widget = CheckBox @@ -40,8 +40,8 @@ class TestCheckbox(WidgetTest): expected = '' def test_value_false(self): - params = {'value':False} - expected = '' + params = {'value': False} + expected = '' for engine in self._get_all_possible_engines(): yield self._check_rendering_vs_expected, engine, self.attrs, params, expected diff --git a/tw2/forms/widgets.py b/tw2/forms/widgets.py index 8f2137e..b4cbbec 100755 --- a/tw2/forms/widgets.py +++ b/tw2/forms/widgets.py @@ -60,7 +60,7 @@ class CheckBox(InputField): def prepare(self): super(CheckBox, self).prepare() self.safe_modify('attrs') - self.attrs['checked'] = self.value and 'checked' or None + self.attrs['checked'] = 'checked' if self.value in [True, 'checked'] else None self.value = None