def test_normal(self, method, strict_level, value, expected): from typepy import Nan, StrictLevel actual = convert_wrapper(typepy.RealNumber(value, strict_level), method) if Nan(expected, strict_level=StrictLevel.MIN).is_type(): assert Nan(actual, strict_level=StrictLevel.MIN).is_type() else: assert actual == expected
def __modify_item(data): try: return typepy.Integer(data).convert() except typepy.TypeConversionError: pass try: return typepy.RealNumber(data).convert() except typepy.TypeConversionError: pass return MultiByteStrDecoder(data).unicode_str
def to_query(self) -> str: value = self._value if value is None: return "NULL" if typepy.Integer(value).is_type() or typepy.RealNumber( value).is_type(): return str(value) try: if value.find("'") != -1: return f'"{value}"' except (TypeError, AttributeError): pass return f"'{value}'"
def to_query(self): value = self._value if value is None: return "NULL" if typepy.Integer(value).is_type() or typepy.RealNumber( value).is_type(): return six.text_type(value) try: if value.find("'") != -1: return '"{}"'.format(value) except (TypeError, AttributeError): pass return "'{}'".format(value)
def __get_unit(self): if typepy.RealNumber(self.__readable_time).is_type(): # if the input value is real numbers consider unit as milliseconds. return "ms" return _RE_NUMBER.sub("", self.__readable_time).strip().lower()
def test_normal_float_type(self, value, float_type, expected): result = typepy.RealNumber(value, strict_level=StrictLevel.MIN, float_type=float_type).convert() assert result == expected