77"""
88
99import unittest
10+ from unittest .mock import patch
1011
1112from speech .shortcutKeys import (
1213 _getKeyboardShortcutSpeech ,
1314 getKeyboardShortcutsSpeech ,
1415)
16+ import speech .shortcutKeys
1517from speech .commands import CharacterModeCommand
1618
1719
20+ original_shouldUseSpellingFunctionality = speech .shortcutKeys .shouldUseSpellingFunctionality
21+
1822class Test_getKeyboardShortcutSpeech (unittest .TestCase ):
1923
24+ @patch ('speech.shortcutKeys.shouldUseSpellingFunctionality' , lambda : True )
2025 def test_simpleLetterKey (self ):
2126 """A shortcut consisting in only one letter."""
2227
@@ -30,6 +35,21 @@ def test_simpleLetterKey(self):
3035 )
3136 self .assertEqual (repr (output ), expected )
3237
38+ @patch ('speech.shortcutKeys.shouldUseSpellingFunctionality' , lambda : False )
39+ def test_simpleLetterKeyWithSpellingFunctionalityDisabled (self ):
40+ """A shortcut consisting in only one letter in the case where "Use spelling functionality" is disabled
41+ (see #15566).
42+ ."""
43+
44+ expected = repr ([
45+ 'A' ,
46+ ])
47+ output = _getKeyboardShortcutSpeech (
48+ keyboardShortcut = 'A' ,
49+ )
50+ self .assertEqual (repr (output ), expected )
51+
52+
3353 def test_simpleSymbolKey (self ):
3454 """A shortcut consisting in only one symbol present in symbols.dic."""
3555
@@ -52,6 +72,7 @@ def test_simpleKeyName(self):
5272 )
5373 self .assertEqual (repr (output ), expected )
5474
75+ @patch ('speech.shortcutKeys.shouldUseSpellingFunctionality' , lambda : True )
5576 def test_modifiersAndLetterKey (self ):
5677 """A shortcut consisting in modifiers and a letter key."""
5778
@@ -110,6 +131,7 @@ def test_modifierAndPlusKeyDescription(self):
110131 )
111132 self .assertEqual (repr (output ), expected )
112133
134+ @patch ('speech.shortcutKeys.shouldUseSpellingFunctionality' , lambda : True )
113135 def test_sequentialShortcutCombiningSpacesAndCommas (self ):
114136 """A sequential shortcut found in ribbons (e.g. Word)."""
115137
@@ -136,6 +158,7 @@ def test_sequentialShortcutCombiningSpacesAndCommas(self):
136158
137159class Test_getKeyboardShortcutsSpeech (unittest .TestCase ):
138160
161+ @patch ('speech.shortcutKeys.shouldUseSpellingFunctionality' , lambda : True )
139162 def test_twoShortcutKeys (self ):
140163 """A shortcut key indication indicating two shortcut keys (a sequential one and a simultaneous one)
141164 as found in ribbons (e.g. Word).
0 commit comments