示例#1
0
def test_fast_float_converts_float_string_to_float_example():
    assert fast_float('45.8') == 45.8
    assert fast_float('-45') == -45.0
    assert fast_float('45.8e-2', key=len) == 45.8e-2
    assert isnan(fast_float('nan'))
    assert isnan(fast_float('+nan'))
    assert isnan(fast_float('-NaN'))
    assert fast_float('۱۲.۱۲') == 12.12
    assert fast_float('-۱۲.۱۲') == -12.12
示例#2
0
def test_fast_float_converts_float_string_to_float_example():
    assert fast_float("45.8") == 45.8
    assert fast_float("-45") == -45.0
    assert fast_float("45.8e-2", key=len) == 45.8e-2
    assert isnan(fast_float("nan"))
    assert isnan(fast_float("+nan"))
    assert isnan(fast_float("-NaN"))
    assert fast_float("۱۲.۱۲") == 12.12
    assert fast_float("-۱۲.۱۲") == -12.12
def test_fast_float_converts_float_string_to_float_example():
    assert fast_float("45.8") == 45.8
    assert fast_float("-45") == -45.0
    assert fast_float("45.8e-2", key=len) == 45.8e-2
    assert isnan(fast_float("nan"))
    assert isnan(fast_float("+nan"))
    assert isnan(fast_float("-NaN"))
    assert fast_float("۱۲.۱۲") == 12.12
    assert fast_float("-۱۲.۱۲") == -12.12
示例#4
0
def test_locale_convert_with_groupletters_transforms_nonfloat_string_to_strxfrm_string_with_grouped_letters(
        x):
    assume(type(fast_float(x)) is not float)
    load_locale('en_US')
    strxfrm = get_strxfrm()
    assert locale_convert(x, (fast_float, isfloat), True) == strxfrm(''.join(
        chain.from_iterable([low(y), y] for y in x)))
    locale.setlocale(locale.LC_NUMERIC, str(''))
示例#5
0
def test_fast_float_converts_float_string_to_float_example():
    assert fast_float('45.8') == 45.8
    assert fast_float('-45') == -45.0
    assert fast_float('45.8e-2', key=len) == 45.8e-2
    assert isnan(fast_float('nan'))
    assert isnan(fast_float('+nan'))
    assert isnan(fast_float('-NaN'))
def test_fast_float_converts_float_string_to_float_example():
    assert fast_float('45.8') == 45.8
    assert fast_float('-45') == -45.0
    assert fast_float('45.8e-2') == 45.8e-2
    assert isnan(fast_float('nan'))
def test_fast_float_leaves_float_asis_example():
    assert fast_float(45.8) == 45.8
示例#8
0
def test_fast_float_with_key_applies_to_string_example():
    assert fast_float('invalid', key=len) == len('invalid')
示例#9
0
def test_fast_float_leaves_string_as_is_example():
    assert fast_float('invalid') == 'invalid'
示例#10
0
def test_locale_convert_transforms_nonfloat_string_to_strxfrm_string(x):
    assume(type(fast_float(x)) is not float)
    load_locale('en_US')
    strxfrm = get_strxfrm()
    assert locale_convert(x, (fast_float, isfloat), False) == strxfrm(x)
    locale.setlocale(locale.LC_NUMERIC, str(''))
示例#11
0
def test_fast_float_leaves_string_as_is_example():
    assert fast_float("invalid") == "invalid"
def test_fast_float_with_key_applies_to_string(x):
    assert fast_float(x, key=len) == len(x)
def test_fast_float_leaves_string_as_is(x):
    assert fast_float(x) == x
def test_fast_float_leaves_string_as_is_example():
    assert fast_float("invalid") == "invalid"
示例#15
0
def test_fast_float_leaves_string_as_is_example():
    assert fast_float('invalid') == 'invalid'
def test_fast_float_converts_float_string_to_float(x):
    assert fast_float(repr(x)) == x
示例#17
0
def test_fast_float_with_key_applies_to_string(x):
    assume(not is_float(x))
    assume(bool(x))
    assert fast_float(x, key=len) == len(x)
示例#18
0
def test_grouper_returns_letters_with_lowercase_transform_of_letter(x):
    assume(type(fast_float(x)) is not float)
    assert grouper(x, (fast_float, isfloat)) == ''.join(
        chain.from_iterable([low(y), y] for y in x))
示例#19
0
def test_fast_float_with_key_applies_to_string(x):
    assert fast_float(x, key=len) == len(x)
示例#20
0
def test_fast_float_returns_nan_alternate_if_nan_option_is_given():
    assert fast_float('nan', nan=7) == 7
示例#21
0
def test_fast_float_returns_nan_alternate_if_nan_option_is_given():
    assert fast_float('nan', nan=7) == 7
示例#22
0
def test_fast_float_converts_float_string_to_float(x):
    assume(not isnan(x))  # But inf is included
    assert fast_float(repr(x)) == x
示例#23
0
def test_fast_float_converts_float_string_to_float(x):
    assert fast_float(repr(x)) == x
示例#24
0
def test_fast_float_leaves_string_as_is(x):
    assume(not is_float(x))
    assume(bool(x))
    assert fast_float(x) == x
示例#25
0
def test_fast_float_leaves_string_as_is(x):
    assert fast_float(x) == x
示例#26
0
def test_fast_float_with_key_applies_to_string(x):
    assume(not is_float(x))
    assume(bool(x))
    assert fast_float(x, key=len) == len(x)
示例#27
0
def test_fast_float_with_key_applies_to_string_example():
    assert fast_float('invalid', key=len) == len('invalid')
示例#28
0
def test_fast_float_leaves_float_asis(x):
    assume(not isnan(x))  # But inf is included
    assert fast_float(x) == x
示例#29
0
def test_grouper_returns_letters_with_lowercase_transform_of_letter(x):
    assume(type(fast_float(x)) is not float)
    assert grouper(x, (fast_float, isfloat)) == ''.join(chain.from_iterable([low(y), y] for y in x))
示例#30
0
def test_fast_float_converts_float_string_to_float(x):
    assume(not isnan(x))  # But inf is included
    assert fast_float(repr(x)) == x
示例#31
0
def test_locale_convert_transforms_nonfloat_string_to_strxfrm_string(x):
    assume(type(fast_float(x)) is not float)
    load_locale('en_US')
    strxfrm = get_strxfrm()
    assert locale_convert(x, (fast_float, isfloat), False) == strxfrm(x)
    locale.setlocale(locale.LC_NUMERIC, str(''))
示例#32
0
def test_fast_float_leaves_string_as_is(x):
    assume(not is_float(x))
    assert fast_float(x) == x
示例#33
0
def test_locale_convert_with_groupletters_transforms_nonfloat_string_to_strxfrm_string_with_grouped_letters(x):
    assume(type(fast_float(x)) is not float)
    load_locale('en_US')
    strxfrm = get_strxfrm()
    assert locale_convert(x, (fast_float, isfloat), True) == strxfrm(''.join(chain.from_iterable([low(y), y] for y in x)))
    locale.setlocale(locale.LC_NUMERIC, str(''))