forked from ModOrganizer2/modorganizer-plugin_python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_guessed_string.py
More file actions
36 lines (25 loc) · 865 Bytes
/
test_guessed_string.py
File metadata and controls
36 lines (25 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import mobase
import mobase_tests.guessed_string as m
def test_guessed_string():
# empty string
gs = mobase.GuessedString()
assert len(gs.variants()) == 0
assert not gs.variants()
assert str(gs) == ""
# automatic conversion from string
assert m.get_value("test") == "test"
assert m.get_variants("test") == {"test"}
# update
gs = mobase.GuessedString("fallback", mobase.GuessQuality.FALLBACK)
assert str(gs) == "fallback"
gs.update("good", mobase.GuessQuality.GOOD)
assert str(gs) == "good"
assert gs.variants() == {"fallback", "good"}
# back-and-forth
gs = mobase.GuessedString()
assert str(gs) == ""
def _update(gs: mobase.GuessedString):
gs.update("test")
m.set_from_callback(gs, _update)
assert str(gs) == "test"
assert m.get_from_callback(_update) == "test"