MCPcopy Create free account
hub / github.com/Pylons/webtest / lint

Method lint

webtest/forms.py:553–569  ·  view source on GitHub ↗

Check that the html is valid: - each field must have an id - each field must have a label

(self)

Source from the content-addressed store, hash-verified

551 return fields[0]
552
553 def lint(self):
554 """
555 Check that the html is valid:
556
557 - each field must have an id
558 - each field must have a label
559
560 """
561 labels = self._label_re.findall(self.text)
562 for name, fields in self.fields.items():
563 for field in fields:
564 if not isinstance(field, (Submit, Hidden)):
565 if not field.id:
566 raise AttributeError("%r as no id attribute" % field)
567 elif field.id not in labels:
568 raise AttributeError(
569 "%r as no associated label" % field)
570
571 def set(self, name, value, index=None):
572 """Set the given name, using ``index`` to disambiguate."""

Callers 1

test_form_lintMethod · 0.95

Calls 1

itemsMethod · 0.80

Tested by 1

test_form_lintMethod · 0.76