mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 00:14:44 +01:00
test-translations: display all hotkey conflicts at once
... instead of erroring out at the first conflict. Also display all options involved in a hotkey conflict to make fixing it easier.
This commit is contained in:
parent
d52b301ee8
commit
3e7e9bf01f
1 changed files with 13 additions and 1 deletions
|
@ -59,6 +59,8 @@ class TestHotkeyConflicts(AATest):
|
|||
# we also want to detect hotkey conflicts in the untranslated english strings
|
||||
self.languages.append('C')
|
||||
|
||||
conflicts = []
|
||||
|
||||
for language in self.languages:
|
||||
with self.subTest(language=language):
|
||||
t = gettext.translation(
|
||||
|
@ -67,15 +69,25 @@ class TestHotkeyConflicts(AATest):
|
|||
)
|
||||
|
||||
keys = {}
|
||||
all_keys = []
|
||||
found_conflict = ''
|
||||
|
||||
for key in params:
|
||||
text = t.gettext(CMDS[key])
|
||||
all_keys.append(text)
|
||||
hotkey = get_translated_hotkey(text)
|
||||
|
||||
if keys.get(hotkey):
|
||||
raise Exception("Hotkey conflict: '{}' and '{}'".format(keys[hotkey], text))
|
||||
found_conflict = "Hotkey conflict for {}: '{}' and '{}'".format(language, keys[hotkey], text)
|
||||
else:
|
||||
keys[hotkey] = text
|
||||
|
||||
if found_conflict:
|
||||
conflicts.append("{}\n {}'".format(found_conflict, ' '.join(all_keys)))
|
||||
|
||||
if conflicts:
|
||||
raise Exception('\n'.join(conflicts))
|
||||
|
||||
|
||||
setup_all_loops(__name__)
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Add table
Reference in a new issue