def test_point_field(self): f = PointField() pytest.raises(ValidationError, f.clean, None) pytest.raises(ValidationError, f.clean, 'a') pytest.raises(ValidationError, f.clean, []) pytest.raises(ValidationError, f.clean, [1]) pytest.raises(ValidationError, f.clean, [1, 2, 3, 4]) pytest.raises(ValidationError, f.clean, [1, 2, 'a', 4]) assert (1, 2) == f.clean((1, 2)) assert (1, 2) == f.clean(('1', '2')) assert (1, 2, 3) == f.clean((1, 2, 3)) assert (1, 2, 3) == f.clean(('1', '2', '3')) assert isinstance(f.clean((1, 2)), point) assert isinstance(f.clean((1, 2, 3)), point)
def test_point_field(self): f = PointField() self.assertRaises(ValidationError, f.clean, None) self.assertRaises(ValidationError, f.clean, 'a') self.assertRaises(ValidationError, f.clean, []) self.assertRaises(ValidationError, f.clean, [1]) self.assertRaises(ValidationError, f.clean, [1, 2, 3, 4]) self.assertRaises(ValidationError, f.clean, [1, 2, 'a', 4]) self.assertEqual((1, 2), f.clean((1, 2))) self.assertEqual((1, 2), f.clean(('1', '2'))) self.assertEqual((1, 2, 3), f.clean((1, 2, 3))) self.assertEqual((1, 2, 3), f.clean(('1', '2', '3'))) self.assertIsInstance(f.clean((1, 2)), point) self.assertIsInstance(f.clean((1, 2, 3)), point)