Skip to content

Commit 859f7d6

Browse files
tests(translator): test with prefix and custom translation
1 parent 995d2f2 commit 859f7d6

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

tests/test_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def on_change(**_):
109109
def another_method():
110110
pass
111111

112-
assert server.state._change_callbacks["a"][0] == on_change
112+
assert server.state._change_callbacks["a"][0][0] == on_change
113113
assert server.trigger_name(another_method) == "my_name"
114114
assert server.name == "test_enable_module"
115115

tests/test_translator.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ def test_translator():
3333
assert b_translator.reverse_translate_key("b_foo") == "foo"
3434
assert b_translator.reverse_translate_key("b_bar") == "bar"
3535

36+
c_translator = Translator()
37+
c_translator.set_prefix("c_")
38+
c_translator.add_translation("foo", "still_foo")
39+
40+
assert c_translator.translate_key("foo") == "still_foo"
41+
assert c_translator.translate_key("bar") == "c_bar"
42+
assert c_translator.reverse_translate_key("still_foo") == "foo"
43+
assert c_translator.reverse_translate_key("c_foo") == "foo"
44+
assert c_translator.reverse_translate_key("c_bar") == "bar"
45+
3646

3747
def test_state_translation():
3848
root_state = State()

0 commit comments

Comments
 (0)