| 296 | class TestFormLint(unittest.TestCase): |
| 297 | |
| 298 | def test_form_lint(self): |
| 299 | def _build_response(html): |
| 300 | return webtest.TestResponse('<body>{}</body>'.format(html)) |
| 301 | |
| 302 | html = '''<form> |
| 303 | <input type="text" name="field"/> |
| 304 | </form>''' |
| 305 | form = webtest.Form(_build_response(html), html) |
| 306 | self.assertRaises(AttributeError, form.lint) |
| 307 | |
| 308 | html = '''<form> |
| 309 | <input type="text" id="myfield" name="field"/> |
| 310 | </form>''' |
| 311 | form = webtest.Form(_build_response(html), html) |
| 312 | self.assertRaises(AttributeError, form.lint) |
| 313 | |
| 314 | html = '''<form> |
| 315 | <label for="myfield">my field</label> |
| 316 | <input type="text" id="myfield" name="field"/> |
| 317 | </form>''' |
| 318 | form = webtest.Form(_build_response(html), html) |
| 319 | form.lint() |
| 320 | |
| 321 | html = '''<form> |
| 322 | <label class="field" for="myfield" role="r">my field</label> |
| 323 | <input type="text" id="myfield" name="field"/> |
| 324 | </form>''' |
| 325 | form = webtest.Form(_build_response(html), html) |
| 326 | form.lint() |
| 327 | |
| 328 | |
| 329 | def select_app(environ, start_response): |