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
def test_translate(): schema = Schema("test", {}) assert engine.translate("Iuliia", schema) == "Iuliia"
def test_short_word(): schema = Schema("test", {}) assert engine.translate("Iu", schema) == "Iu"
def test_empty_word(): schema = Schema("test", {}) assert engine.translate("", schema) == ""
def test_ending_mapping(): schema = Schema("test", {}, ending_mapping={"ia": "ya"}) assert engine.translate("Iuliia", schema) == "Iuliya"
def test_next_mapping(): schema = Schema("test", {}, next_mapping={"iu": "y"}) assert engine.translate("Iuliia", schema) == "Yuliia"
def test_prev_mapping(): schema = Schema("test", {}, prev_mapping={"li": ""}) assert engine.translate("Iuliia", schema) == "Iulia"
def test_mapping(): schema = Schema("test", {"a": "1", "i": "2", "l": "3", "u": "4"}) assert engine.translate("Iuliia", schema) == "243221"
def _schema_loader(): return (Schema.load(defn) for defn in _definition_reader())