77"""
88
99import unittest
10+ from unittest .mock import patch
1011
1112from speech .shortcutKeys import (
1213 _getKeyboardShortcutSpeech ,
1314 getKeyboardShortcutsSpeech ,
1415)
16+ import speech .shortcutKeys # noqa F401 - Used by unittest.mock.patch
1517from speech .commands import CharacterModeCommand
1618
1719
1820class Test_getKeyboardShortcutSpeech (unittest .TestCase ):
1921
22+ @patch ('speech.shortcutKeys.shouldUseSpellingFunctionality' , lambda : True )
2023 def test_simpleLetterKey (self ):
2124 """A shortcut consisting in only one letter."""
2225
@@ -30,6 +33,19 @@ def test_simpleLetterKey(self):
3033 )
3134 self .assertEqual (repr (output ), expected )
3235
36+ @patch ('speech.shortcutKeys.shouldUseSpellingFunctionality' , lambda : False )
37+ def test_simpleLetterKeyWithSpellingFunctionalityDisabled (self ):
38+ """A shortcut consisting in only one letter in the case where "Use spelling functionality" is disabled
39+ (see #15566).
40+ """
41+
42+ expected = repr (['A' ,])
43+ output = _getKeyboardShortcutSpeech (
44+ keyboardShortcut = 'A' ,
45+ )
46+ self .assertEqual (repr (output ), expected )
47+
48+
3349 def test_simpleSymbolKey (self ):
3450 """A shortcut consisting in only one symbol present in symbols.dic."""
3551
@@ -52,6 +68,7 @@ def test_simpleKeyName(self):
5268 )
5369 self .assertEqual (repr (output ), expected )
5470
71+ @patch ('speech.shortcutKeys.shouldUseSpellingFunctionality' , lambda : True )
5572 def test_modifiersAndLetterKey (self ):
5673 """A shortcut consisting in modifiers and a letter key."""
5774
@@ -110,6 +127,7 @@ def test_modifierAndPlusKeyDescription(self):
110127 )
111128 self .assertEqual (repr (output ), expected )
112129
130+ @patch ('speech.shortcutKeys.shouldUseSpellingFunctionality' , lambda : True )
113131 def test_sequentialShortcutCombiningSpacesAndCommas (self ):
114132 """A sequential shortcut found in ribbons (e.g. Word)."""
115133
@@ -136,6 +154,7 @@ def test_sequentialShortcutCombiningSpacesAndCommas(self):
136154
137155class Test_getKeyboardShortcutsSpeech (unittest .TestCase ):
138156
157+ @patch ('speech.shortcutKeys.shouldUseSpellingFunctionality' , lambda : True )
139158 def test_twoShortcutKeys (self ):
140159 """A shortcut key indication indicating two shortcut keys (a sequential one and a simultaneous one)
141160 as found in ribbons (e.g. Word).
0 commit comments