Ejemplo n.º 1
0
def test_html_returns_unicode():
    body_text = html.div(
        html.p(u"£")).encode('utf-8')
    agent = TestAgent(wz.Response([body_text]))
    page = agent.get(u'/')
    assert page.html() == body_text.decode('utf-8')
    assert page.html('utf-8') == body_text
Ejemplo n.º 2
0
def test_lxml_attr_is_consistent():
    body_text = html.div(
        html.p(u"foo")).encode('utf-8')
    agent = TestAgent(wz.Response([body_text]))
    page = agent.get(u'/')
    div_element = page.one('//div')
    assert page.lxml == div_element.lxml
Ejemplo n.º 3
0
def test_unicode_chars():
    body_text = html.div(
        html.p(u"£")).encode('utf-8')
    agent = TestAgent(wz.Response([body_text]))
    page = agent.get(u'/')
    assert page.body == body_text
    assert tostring(page.lxml) == body_text
    assert page.html().encode('utf-8') == body_text
    div_element = page.one('//div')
    assert div_element.html().encode('utf-8') == body_text
    assert tostring(div_element.lxml) == body_text
Ejemplo n.º 4
0
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"]