Esempio n. 1
0
def test_readme_example_2():
    assert strint("twenty-three hours, fifty-nine minutes,"
                  " 40 short seconds and 20 long seconds") == {
                      "hours": 23,
                      "minutes": 59,
                      "short seconds": 40,
                      "long seconds": 20
                  }
Esempio n. 2
0
def test_hyphen_thing_consisting_of_two_prefixes():
    assert strint("tera-mega") == (10**12) * (10**6)
Esempio n. 3
0
def test_prefix_with_hyphen():
    assert strint("giga-million") == (10**9) * (10**6)
Esempio n. 4
0
def test_hyphen_in_other_weird_places():
    with pytest.raises(ValueError):
        _ = strint("one-two")
Esempio n. 5
0
def test_hyphen_in_weird_places():
    assert strint("one-million") == 1_000_000
Esempio n. 6
0
def test_multiple_with_same_unit():
    assert strint("one banana and one banana") == {"banana": 2}
Esempio n. 7
0
def test_and_in_unit_name():
    assert strint("forty evil and roids") == {"evil and roids": 40}
Esempio n. 8
0
def test_some_string_thing():
    assert strint("which one of these three") == {None: 3, "of these": 1}
Esempio n. 9
0
def test_readme_example_1():
    assert strint("two octillion gigadollars and twelve cents") == {
        "dollars": 2 * (10**27) * (10**9),
        "cents": 12,
    }
Esempio n. 10
0
def test_prefixed_exponent_words():
    assert strint(
        "twelve gigamillion ties and one megagigatrillion and one hats") == {
            "ties": 12 * (10**9) * (10**6),
            "hats": (10**6) * (10**9) * (10**12) + 1,
        }
Esempio n. 11
0
def test_reject_prefixed_non_exponent_word():
    with pytest.raises(ValueError):
        _ = strint("megaten")
Esempio n. 12
0
def test_prefix_only():
    assert strint("hecto") == 100
Esempio n. 13
0
def test_readme_example_3():
    assert strint("one, two, one two and three and four") == 13
Esempio n. 14
0
def test_bigger_part_followed_by_smaller_and_then_bigger_again():
    assert strint("two hundred and ninety-one thousand") == 291_000
Esempio n. 15
0
def test_prefixed_unit_with_hyphen():
    assert strint("mega-fun") == {"fun": 1_000_000}
Esempio n. 16
0
def test_multiword_units():
    assert strint("99 megamillion bottles of beer on the wall") == {
        "bottles of beer on the wall": 99 * (10**6) * (10**6)
    }
Esempio n. 17
0
def test_prefixed_number_with_hyphen():
    with pytest.raises(ValueError):
        _ = strint("kilo-twenty")
Esempio n. 18
0
def test_and_stripping():
    assert strint("and one more thing") == {"more thing": 1}
    assert strint("one more thing and") == {"more thing": 1}
Esempio n. 19
0
def test_hyphenated_words_with_no_numeric_significance():
    assert strint("five test-cases") == {"test-cases": 5}
    assert strint("a million bad bug-reports") == {
        "bad bug-reports": 1_000_000
    }
Esempio n. 20
0
def test_and_after_parsed_token():
    assert strint("five and ten") == 15