Simple selector tests
(self)
| 13 | |
| 14 | class TestSelector: |
| 15 | def test_simple_selection(self): |
| 16 | """Simple selector tests""" |
| 17 | body = b"<p><input name='a'value='1'/><input name='b'value='2'/></p>" |
| 18 | response = TextResponse(url="http://example.com", body=body, encoding="utf-8") |
| 19 | sel = Selector(response) |
| 20 | |
| 21 | xl = sel.xpath("//input") |
| 22 | assert len(xl) == 2 |
| 23 | for x in xl: |
| 24 | assert isinstance(x, Selector) |
| 25 | |
| 26 | assert sel.xpath("//input").getall() == [x.get() for x in sel.xpath("//input")] |
| 27 | assert [x.get() for x in sel.xpath("//input[@name='a']/@name")] == ["a"] |
| 28 | assert [ |
| 29 | x.get() |
| 30 | for x in sel.xpath( |
| 31 | "number(concat(//input[@name='a']/@value, //input[@name='b']/@value))" |
| 32 | ) |
| 33 | ] == ["12.0"] |
| 34 | assert sel.xpath("concat('xpath', 'rules')").getall() == ["xpathrules"] |
| 35 | assert [ |
| 36 | x.get() |
| 37 | for x in sel.xpath( |
| 38 | "concat(//input[@name='a']/@value, //input[@name='b']/@value)" |
| 39 | ) |
| 40 | ] == ["12"] |
| 41 | |
| 42 | def test_root_base_url(self): |
| 43 | body = b'<html><form action="/path"><input name="a" /></form></html>' |
nothing calls this directly
no test coverage detected