4 examples of 'python isdecimal' in Python

Every line of 'python isdecimal' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
78def pythonvalue(self, value):
79 return _Decimal(value)
281def test_decimal():
282 """
283 messages:
284 - INVALID_DECIMAL
285 - NUMBER_TOO_LOW
286 - NUMBER_TOO_HIGH
287 """
288
289 class Data(Model):
290 a = DecimalType(min_value=-10, max_value=10)
291
292 INVALID = ["", "a", "2a", "2015-05-13 13:35:15"]
293 VALID = [
294 "1",
295 "-2",
296 "8",
297 "2.3",
298 "5.2354958",
299 "-9.231",
300 1,
301 -2,
302 8,
303 2.3,
304 5.2354958,
305 -9.231,
306 ]
307 _test_valid_invalid(
308 model=Data,
309 valid=VALID,
310 invalid=INVALID,
311 expected_error=messages.INVALID_DECIMAL,
312 )
313 _test_data(
314 model=Data, data={"a": -20}, expected=(False, {"a": [messages.NUMBER_TOO_LOW]})
315 )
316 _test_data(
317 model=Data, data={"a": 11}, expected=(False, {"a": [messages.NUMBER_TOO_HIGH]})
318 )
33def test_decimal(self):
34 self.assertEqual(Decimal('2.3'), mathfilters.valid_numeric(Decimal('2.3')))
35 self.assertEqual(Decimal('-2.3'), mathfilters.valid_numeric(Decimal('-2.3')))
60def test_decimal_int(self):
61 a, b = mathfilters.handle_float_decimal_combinations(Decimal('2.0'), 1, '+')
62 self.assertTrue(isinstance(a, Decimal), 'Type is {0}'.format(type(a)))
63 self.assertTrue(isinstance(b, int), 'Type is {0}'.format(type(b)))

Related snippets