def test_get_case_form_returns_correct_values():
    word = Word(u"dzień", "m inan")
    word.set_case_forms(
        "singular", {"nominative": "dzień", "instrumental": "dniem"})
    word.set_case_forms("plural", {"nominative": "dni", "locative": "dniach"})
    assert word.get_case_form("singular", "nominative") == "dzień"
    assert word.get_case_form("plural", "nominative") == "dni"
    assert word.get_case_form("plural", "locative") == "dniach"
def test_list_case_forms():
    word = Word(u"dzień", "m inan")
    assert word.list_case_forms() == []
    word.set_case_forms(
        "singular", {"nominative": "dzień", "instrumental": "dniem"})
    word.set_case_forms("plural", {"nominative": "dni", "locative": "dniach"})
    assert set(word.list_case_forms()) == set([
        ("singular", "nominative"),
        ("singular", "instrumental"),
        ("plural", "nominative"),
        ("plural", "locative"),
    ])
Exemplo n.º 3
0
def test_instantiation_fails_without_arguments():
    with pytest.raises(TypeError):
        word = Word()
Exemplo n.º 4
0
def test_supports_method_correctly_identifies_available_case_forms():
    word = Word(u"dzień", "m inan")
    word.set_case_forms("singular", {"nominative": "dzień"})
    assert word.supports("singular", "accusative") is False
    assert word.supports("plural", "nominative") is False
    assert word.supports("singular", "nominative") is True
Exemplo n.º 5
0
def test_supports_method_works_with_unset_case_forms():
    word = Word(u"dzień", "m inan")
    assert word.supports("singular", "accusative") is False
Exemplo n.º 6
0
def test_set_case_forms_accepts_valid_data():
    word = Word(u"dzień", "m inan")
    word.set_case_forms("singular", {"nominative": "dzień"})
Exemplo n.º 7
0
def test_setting_case_forms_needs_dict():
    word = Word(u"dzień", "m inan")
    with pytest.raises(TypeError):
        word.set_case_forms("m inan", None)
Exemplo n.º 8
0
def test_instantiated_values_are_accessible_via_getters():
    basic_form = u"dzień"
    gender = "m inan"
    word = Word(basic_form, gender)
    assert word.get_basic_form() == basic_form
    assert word.get_gender() == gender
Exemplo n.º 9
0
def test_instantiation_accepts_valid_values():
    basic_form = u"dzień"
    gender = "m inan"
    word = Word(basic_form, gender)
Exemplo n.º 10
0
def test_instantiation_succeeds_with_arguments():
    word = Word(u"dzień", "m inan")
Exemplo n.º 11
0
def test_clear_case_forms_functions_as_advertised():
    word = Word(u"dzień", "m inan")
    word.set_case_forms("singular", {
        "nominative": "dzień",
        "instrumental": "dniem"
    })
    word.set_case_forms("plural", {"nominative": "dni", "locative": "dniach"})
    assert word.get_case_form("singular", "nominative") == "dzień"
    assert word.get_case_form("plural", "nominative") == "dni"
    assert word.get_case_form("plural", "locative") == "dniach"
    word.clear_case_forms()
    assert not word.supports("singular", "nominative")
    assert not word.supports("plural", "nominative")
    assert not word.supports("plural", "locative")
Exemplo n.º 12
0
def test_instantiation_fails_without_arguments():
    word = Word()
Exemplo n.º 13
0
def test_get_case_form_throws_error_for_non_supported_forms():
    word = Word(u"dzień", "m inan")
    word.get_case_form("singular", "nominative")
Exemplo n.º 14
0
def test_setting_case_forms_needs_dict():
    word = Word(u"dzień", "m inan")
    word.set_case_forms("m inan", None)
Exemplo n.º 15
0
def test_get_case_form_throws_error_for_non_supported_forms():
    word = Word(u"dzień", "m inan")
    with pytest.raises(CaseNotSupported):
        word.get_case_form("singular", "nominative")
Exemplo n.º 16
0
def test_set_case_forms_overwrites_all_for_specific_number():
    word = Word(u"dzień", "m inan")
    word.set_case_forms("singular", {
        "nominative": "dzień",
        "instrumental": "dniem"
    })
    word.set_case_forms("plural", {"nominative": "dni", "locative": "dniach"})
    # Overwrite the values for singular
    word.set_case_forms("singular", {
        "nominative": "something",
        "vocative": "else"
    })
    assert not word.supports("singular", "instrumental")
    assert word.get_case_form("singular", "nominative") == "something"
    assert word.get_case_form("singular", "vocative") == "else"
    assert word.get_case_form("plural", "nominative") == "dni"
    assert word.get_case_form("plural", "locative") == "dniach"
Exemplo n.º 17
0
def test_instantiation_fails_with_empty_gender():
    basic_form = "kolor"
    gender = ""
    with pytest.raises(ValueError):
        word = Word(basic_form, gender)