def test_form_getitem_doesnt_match(): form_text = html.body( html.form( html.input(name="foo", value="a")), html.input(name="foo", value="b")) agent = TestAgent(wz.Response([form_text])) form_page = agent.get(u'/') form = form_page.one(u"//form") assert form[u"foo"] == u"a"
def radio_button(name, value='yes', checked=False, **attr): """Render a checkbox.""" return html.input(type='radio', value=value, name=name, checked=checked, **attr)
def checkbox(name, checked=False, value='yes', **attr): """Render a checkbox.""" return html.input(type='checkbox', name=name, value=value, checked=checked, **attr)
def test_form_getitem(): form_text = html.div( html.p( html.input(type="text", name="foo", value="flam")), html.p( html.select( html.option(value="a", selected=True), html.option(value="b"), name="bar")) ) form_page = TestAgent(FormApp(form_text)).get(u'/') form = form_page.one(u'//form') assert form['foo'] == "flam" assert form['bar'] == "a" form["foo"] = u"flibble" form["bar"] = u"a" assert form.one(u'//input').value == u'flibble' assert form.one(u'//select').value == u'a' # Test checkboxes form_page = TestAgent(TestApp()).get('/form-checkbox') form = form_page.one('//form') assert form['a'] == [] assert form['b'] == ["A"]
def input_field(name, value='', type='text', **attr): """Render an input field.""" return html.input(name=name, value=value, type=type, **attr)