Exemplo n.º 1
0
def test_add_morphology_with_int_ids(morphology):
    morphology.strings.add("Case")
    morphology.strings.add("gen")
    morphology.strings.add("Number")
    morphology.strings.add("sing")
    morphology.add(
        {
            get_string_id("Case"): get_string_id("gen"),
            get_string_id("Number"): get_string_id("sing"),
        }
    )
def test_table_api():
    table = Table(name="table")
    assert table.name == "table"
    assert len(table) == 0
    assert "abc" not in table
    data = {"foo": "bar", "hello": "world"}
    table = Table(name="table", data=data)
    assert len(table) == len(data)
    assert "foo" in table
    assert get_string_id("foo") in table
    assert table["foo"] == "bar"
    assert table[get_string_id("foo")] == "bar"
    assert table.get("foo") == "bar"
    assert table.get("abc") is None
    table["abc"] = 123
    assert table["abc"] == 123
    assert table[get_string_id("abc")] == 123
    table.set("def", 456)
    assert table["def"] == 456
    assert table[get_string_id("def")] == 456
def test_table_api_to_from_bytes():
    data = {"foo": "bar", "hello": "world", "abc": 123}
    table = Table(name="table", data=data)
    table_bytes = table.to_bytes()
    new_table = Table().from_bytes(table_bytes)
    assert new_table.name == "table"
    assert len(new_table) == 3
    assert new_table["foo"] == "bar"
    assert new_table[get_string_id("foo")] == "bar"
    new_table2 = Table(data={"def": 456})
    new_table2.from_bytes(table_bytes)
    assert len(new_table2) == 3
    assert "def" not in new_table2
Exemplo n.º 4
0
def test_add_morphology_with_mix_strings_and_ints(morphology):
    morphology.add({get_string_id("PunctSide_ini"), "VerbType_aux"})
Exemplo n.º 5
0
def test_add_morphology_with_int_ids(morphology):
    morphology.add({get_string_id("Case_gen"), get_string_id("Number_sing")})