[wwwsearch-commits] r17948 - wwwsearch/ClientForm/branch/0.1-maint
jjlee at codespeak.net
jjlee at codespeak.net
Wed Sep 28 21:41:29 CEST 2005
Author: jjlee
Date: Wed Sep 28 21:41:28 2005
New Revision: 17948
Modified:
wwwsearch/ClientForm/branch/0.1-maint/test.py
Log:
More work on testing disabled list items
Modified: wwwsearch/ClientForm/branch/0.1-maint/test.py
==============================================================================
--- wwwsearch/ClientForm/branch/0.1-maint/test.py (original)
+++ wwwsearch/ClientForm/branch/0.1-maint/test.py Wed Sep 28 21:41:28 2005
@@ -1541,6 +1541,11 @@
base_uri = "http://auth.athensams.net/"
def test_deselect_disabled(self):
+ def get_new_form(f):
+ f.seek(0)
+ form = ClientForm.ParseFile(f, "http://example.com/")[0]
+ return form
+
f = StringIO("""\
<form>
<input type="checkbox" name="p" value="a" disabled checked></input>
@@ -1548,22 +1553,50 @@
<input type="checkbox" name="p" value="c"></input>
</form>
""")
- def new_form():
- f.seek(0)
- form = ClientForm.ParseFile(f, "http://example.com/")[0]
+ def new_form(f=f, get_new_form=get_new_form):
+ form = get_new_form(f)
ctl = form.find_control("p")
- return form, ctl
- form, ctl = new_form()
+ return ctl
+
+ ctl = new_form()
ctl.value = ["b"]
# rationale: allowed to deselect, but not select, disabled
# items
- form, ctl = new_form()
+ ctl = new_form()
+ self.assertRaises(AttributeError, ctl.set, True, "a")
+ self.assertRaises(AttributeError, setattr, ctl, "value", ["a"])
+ ctl.set(False, "a")
+ ctl = new_form()
+ ctl.value = ["b"]
+ self.assertEqual(ctl.value, ["b"])
+ ctl = new_form()
+ self.assertRaises(AttributeError, setattr, ctl, "value", ["a", "b"])
+
+ f = StringIO("""\
+<form>
+ <input type="radio" name="p" value="a" disabled checked></input>
+ <input type="radio" name="p" value="b"></input>
+ <input type="radio" name="p" value="c"></input>
+</form>
+""")
+ def new_form(f=f, get_new_form=get_new_form):
+ form = get_new_form(f)
+ ctl = form.find_control("p")
+ return ctl
+
+ ctl = new_form()
+ ctl.value = ["b"]
+
+ ctl = new_form()
self.assertRaises(AttributeError, ctl.set, True, "a")
self.assertRaises(AttributeError, setattr, ctl, "value", ["a"])
ctl.set(False, "a")
- form, ctl = new_form()
+ ctl = new_form()
ctl.value = ["b"]
+ self.assertEqual(ctl.value, ["b"])
+ ctl = new_form()
+ self.assertRaises(ItemCountError, setattr, ctl, "value", ["a", "b"])
def test_click(self):
file = StringIO(
More information about the wwwsearch-commits
mailing list