def test_positive_integer_raises_ValueError(self, mocked_int): mocked_int.return_value = -1 with self.assertRaises(ValueError): validatorfuncs.positive_integer(str(-1)) for pi in ["", "000", "abc", "-1"]: mocked_int.side_effect = ValueError with self.assertRaises(ValueError): validatorfuncs.positive_integer(pi)
def validate(self, value, **kwargs): return validatorfuncs.positive_integer(value, option_key=self.key, **kwargs)
def test_positive_integer_ok(self): for pi in ["123", "4567890", "001"]: self.assertEqual(int(pi), validatorfuncs.positive_integer(pi))
def test_positive_integer_ok(self): for pi in ['123', '4567890', '001']: self.assertEqual(int(pi), validatorfuncs.positive_integer(pi))