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,21 @@ 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 ([
43+ 'A' ,
44+ ])
45+ output = _getKeyboardShortcutSpeech (
46+ keyboardShortcut = 'A' ,
47+ )
48+ self .assertEqual (repr (output ), expected )
49+
50+
3351 def test_simpleSymbolKey (self ):
3452 """A shortcut consisting in only one symbol present in symbols.dic."""
3553
@@ -52,6 +70,7 @@ def test_simpleKeyName(self):
5270 )
5371 self .assertEqual (repr (output ), expected )
5472
73+ @patch ('speech.shortcutKeys.shouldUseSpellingFunctionality' , lambda : True )
5574 def test_modifiersAndLetterKey (self ):
5675 """A shortcut consisting in modifiers and a letter key."""
5776
@@ -110,6 +129,7 @@ def test_modifierAndPlusKeyDescription(self):
110129 )
111130 self .assertEqual (repr (output ), expected )
112131
132+ @patch ('speech.shortcutKeys.shouldUseSpellingFunctionality' , lambda : True )
113133 def test_sequentialShortcutCombiningSpacesAndCommas (self ):
114134 """A sequential shortcut found in ribbons (e.g. Word)."""
115135
@@ -136,6 +156,7 @@ def test_sequentialShortcutCombiningSpacesAndCommas(self):
136156
137157class Test_getKeyboardShortcutsSpeech (unittest .TestCase ):
138158
159+ @patch ('speech.shortcutKeys.shouldUseSpellingFunctionality' , lambda : True )
139160 def test_twoShortcutKeys (self ):
140161 """A shortcut key indication indicating two shortcut keys (a sequential one and a simultaneous one)
141162 as found in ribbons (e.g. Word).
0 commit comments