def set_wordcheck_word_as_default(self): """Set the word selected by the wordcheck cursor as the default for its Entry, and emit signal indicating so.""" word = self.wordcheck_cursor.selectedText() changed: bool = set_entry_default(word, self.regex_map) if changed: self.setup_wordcheck_for_word_under_cursor() self.entry_default_set.emit()
def test_possessive_single_letter(self): # Not ideal but it looks better than adding the `a` stuff to all the string comparisons. Easy fix if needed. add_word_to_dict('a', self.regex_map) res = set_entry_default('a\'s', self.regex_map) self.assertEqual( str(self.regex_map), "{'cat': {'default': 'may', 'words': ['may', 'cat']}, 'a': {'default': 'a', 'words': ['a']}}" ) self.assertTrue(res)
def test_unexpected(self): res = set_entry_default('CAT', self.regex_map) self.assertEqual( str(self.regex_map), "{'cat': {'default': 'CAT', 'words': ['may', 'cat', 'CAT']}}") self.assertTrue(res)
def test_possessive(self): res = set_entry_default('cat\'s', self.regex_map) self.assertEqual( str(self.regex_map), "{'cat': {'default': 'cat', 'words': ['may', 'cat']}}") self.assertTrue(res)
def test_capitalized(self): res = set_entry_default('Cat', self.regex_map) self.assertEqual( str(self.regex_map), "{'cat': {'default': 'cat', 'words': ['may', 'cat']}}") self.assertTrue(res)
def test_missing_entry(self): res = set_entry_default('x', self.regex_map) self.assertEqual( str(self.regex_map), "{'cat': {'default': 'may', 'words': ['may', 'cat']}}") self.assertFalse(res)