def test_clean_none_value(self): field = TextField() self.assertIsNone(field.clean(None))
def test_clean_value(self): field = TextField() self.assertEqual(field.clean(" Hello world. "), "Hello world.")
def test_using_selector_with_eq(self): field = TextField(selector=".link:eq(1)") value = field.get_value(self.pq) self.assertEqual(value, "Another link.")
def test_not_found(self): field = TextField(selector=".not-found") value = field.get_value(self.pq) self.assertIsNone(value)
def test_no_selector(self): field = TextField() value = field.get_value(self.pq) self.assertEqual(value, "Some text. Link text. Another link.")
def test_using_selector(self): field = TextField(selector=".link") value = field.get_value(self.pq) self.assertEqual(value, "Link text.")
def test_coerce_value(self): field = TextField(coerce=int) self.assertEqual(field.coerce("5"), 5)