Ejemplo n.º 1
0
def test_timing():
    mapping = {chr(i): chr(i) for i in range(ord("a"), ord("z"))}
    schema = Schema("test", mapping)
    source = "The quick brown fox jumps over the lazy dog"
    elapsed_sec = timeit.timeit(lambda: engine.translate(source, schema),
                                number=10000)
    max_sec = 1.0
    assert elapsed_sec < max_sec
Ejemplo n.º 2
0
def test_translate():
    schema = Schema("test", {})
    assert engine.translate("Iuliia", schema) == "Iuliia"
Ejemplo n.º 3
0
def test_short_word():
    schema = Schema("test", {})
    assert engine.translate("Iu", schema) == "Iu"
Ejemplo n.º 4
0
def test_empty_word():
    schema = Schema("test", {})
    assert engine.translate("", schema) == ""
Ejemplo n.º 5
0
def test_ending_mapping():
    schema = Schema("test", {}, ending_mapping={"ia": "ya"})
    assert engine.translate("Iuliia", schema) == "Iuliya"
Ejemplo n.º 6
0
def test_next_mapping():
    schema = Schema("test", {}, next_mapping={"iu": "y"})
    assert engine.translate("Iuliia", schema) == "Yuliia"
Ejemplo n.º 7
0
def test_prev_mapping():
    schema = Schema("test", {}, prev_mapping={"li": ""})
    assert engine.translate("Iuliia", schema) == "Iulia"
Ejemplo n.º 8
0
def test_mapping():
    schema = Schema("test", {"a": "1", "i": "2", "l": "3", "u": "4"})
    assert engine.translate("Iuliia", schema) == "243221"
Ejemplo n.º 9
0
def _schema_loader():
    return (Schema.load(defn) for defn in _definition_reader())