diff --git a/plover/formatting.py b/plover/formatting.py index 0ea7f860e..1e06473c7 100644 --- a/plover/formatting.py +++ b/plover/formatting.py @@ -7,6 +7,7 @@ """ +from enum import Enum from os.path import commonprefix from collections import namedtuple import re @@ -16,12 +17,14 @@ from plover.registry import registry -CASE_CAP_FIRST_WORD = 'cap_first_word' -CASE_LOWER = 'lower' -CASE_LOWER_FIRST_CHAR = 'lower_first_char' -CASE_TITLE = 'title' -CASE_UPPER = 'upper' -CASE_UPPER_FIRST_WORD = 'upper_first_word' +Case = Enum('case', ((c, c.lower()) for c in ''' + CAP_FIRST_WORD + LOWER + LOWER_FIRST_CHAR + TITLE + UPPER + UPPER_FIRST_WORD + '''.split())) SPACE = ' ' META_ATTACH_FLAG = '^' @@ -315,7 +318,7 @@ def format(self, undo, do, prev): if last_action is None: # Initial output. next_attach = self.start_attached or self.spaces_after - next_case = CASE_CAP_FIRST_WORD if self.start_capitalized else None + next_case = Case.CAP_FIRST_WORD if self.start_capitalized else None last_action = _Action(next_attach=next_attach, next_case=next_case) ctx = _Context(previous_translations, last_action) for t in do: @@ -687,17 +690,17 @@ def _atom_to_action(atom, ctx): elif meta in META_STOPS: action = _apply_meta_stop(meta, ctx) elif meta == META_CAPITALIZE: - action = _apply_meta_case(CASE_CAP_FIRST_WORD, ctx) + action = _apply_meta_case(Case.CAP_FIRST_WORD, ctx) elif meta == META_LOWER: - action = _apply_meta_case(CASE_LOWER_FIRST_CHAR, ctx) + action = _apply_meta_case(Case.LOWER_FIRST_CHAR, ctx) elif meta == META_UPPER: - action = _apply_meta_case(CASE_UPPER_FIRST_WORD, ctx) + action = _apply_meta_case(Case.UPPER_FIRST_WORD, ctx) elif meta == META_RETRO_CAPITALIZE: - action = _apply_meta_retro_case(CASE_CAP_FIRST_WORD, ctx) + action = _apply_meta_retro_case(Case.CAP_FIRST_WORD, ctx) elif meta == META_RETRO_LOWER: - action = _apply_meta_retro_case(CASE_LOWER_FIRST_CHAR, ctx) + action = _apply_meta_retro_case(Case.LOWER_FIRST_CHAR, ctx) elif meta == META_RETRO_UPPER: - action = _apply_meta_retro_case(CASE_UPPER_FIRST_WORD, ctx) + action = _apply_meta_retro_case(Case.UPPER_FIRST_WORD, ctx) elif (meta.startswith(META_CARRY_CAPITALIZATION) or meta.startswith(META_ATTACH_FLAG + META_CARRY_CAPITALIZATION)): action = _apply_meta_carry_capitalize(meta, ctx) @@ -735,9 +738,9 @@ def _atom_to_action(atom, ctx): # Apply case. case = ctx.last_action.next_case if case is None and action.prev_attach and ctx.last_action.upper_carry: - case = CASE_UPPER_FIRST_WORD + case = Case.UPPER_FIRST_WORD text = _apply_case(text, case) - if case == CASE_UPPER_FIRST_WORD: + if case == Case.UPPER_FIRST_WORD: action.upper_carry = not _has_word_boundary(text) # Apply mode. action.text = _apply_mode(text, action.case, action.space_char, @@ -793,7 +796,7 @@ def _apply_meta_stop(meta, ctx): action = ctx.new_action() action.prev_attach = True action.text = meta - action.next_case = CASE_CAP_FIRST_WORD + action.next_case = Case.CAP_FIRST_WORD return action @@ -864,8 +867,8 @@ def _apply_meta_currency(meta, ctx): def _apply_meta_carry_capitalize(meta, ctx): # Meta format: ^~|content^ (attach flags are optional) action = ctx.new_action() - if ctx.last_action.next_case == CASE_CAP_FIRST_WORD: - action.next_case = CASE_CAP_FIRST_WORD + if ctx.last_action.next_case == Case.CAP_FIRST_WORD: + action.next_case = Case.CAP_FIRST_WORD begin = meta.startswith(META_ATTACH_FLAG) if begin: meta = meta[len(META_ATTACH_FLAG):] @@ -899,17 +902,17 @@ def _apply_meta_mode(meta, ctx): action = ctx.copy_last_action() command = meta[len(META_MODE):] if command == MODE_CAPS: - action.case = CASE_UPPER + action.case = Case.UPPER elif command == MODE_TITLE: - action.case = CASE_TITLE + action.case = Case.TITLE elif command == MODE_LOWER: - action.case = CASE_LOWER + action.case = Case.LOWER elif command == MODE_SNAKE: action.space_char = '_' elif command == MODE_CAMEL: - action.case = CASE_TITLE + action.case = Case.TITLE action.space_char = '' - action.next_case = CASE_LOWER_FIRST_CHAR + action.next_case = Case.LOWER_FIRST_CHAR elif command == MODE_RESET: action.space_char = SPACE action.case = None @@ -925,28 +928,28 @@ def _apply_meta_mode(meta, ctx): def _apply_case(text, case): if case is None: return text - if case == CASE_CAP_FIRST_WORD: + if case == Case.CAP_FIRST_WORD: return _capitalize_first_word(text) - if case == CASE_LOWER_FIRST_CHAR: + if case == Case.LOWER_FIRST_CHAR: return _lower_first_character(text) - if case == CASE_UPPER_FIRST_WORD: + if case == Case.UPPER_FIRST_WORD: return _upper_first_word(text) - raise ValueError('invalid case mode: %s' % case) + raise ValueError('%r is not a valid case' % case) def _apply_mode(text, case, space_char, begin, last_action): # Should title case be applied to the beginning of the next string? lower_title_case = (begin and not last_action.case in ( - CASE_CAP_FIRST_WORD, - CASE_UPPER_FIRST_WORD, + Case.CAP_FIRST_WORD, + Case.UPPER_FIRST_WORD, )) # Apply case, then replace space character text = _apply_mode_case(text, case, lower_title_case) text = _apply_mode_space_char(text, space_char) # Title case is sensitive to lower flag - if (last_action.next_case == CASE_LOWER_FIRST_CHAR - and text and case == CASE_TITLE): + if (last_action.next_case == Case.LOWER_FIRST_CHAR + and text and case == Case.TITLE): text = _lower_first_character(text) return text @@ -954,16 +957,16 @@ def _apply_mode(text, case, space_char, begin, last_action): def _apply_mode_case(text, case, appended): if case is None: return text - if case == CASE_LOWER: + if case == Case.LOWER: return text.lower() - if case == CASE_UPPER: + if case == Case.UPPER: return text.upper() - if case == CASE_TITLE: + if case == Case.TITLE: # Do nothing to appended output if appended: return text return _capitalize_all_words(text) - raise ValueError('invalid case mode: %s' % case) + raise ValueError('%r is not a valid case' % case) def _apply_mode_space_char(text, space_char): diff --git a/test/test_formatting.py b/test/test_formatting.py index 2bc143b68..aa68e7dff 100644 --- a/test/test_formatting.py +++ b/test/test_formatting.py @@ -8,6 +8,7 @@ import pytest from plover import formatting +from plover.formatting import Case from plover_build_utils.testing import CaptureOutput from . import parametrize @@ -111,7 +112,7 @@ def test_starting_stroke(capitalized, attached, undo, do, prev, lambda: ([translation(formatting=[action(text_and_word='test', trailing_space=' ')])], [translation(english='rest')], - [translation(formatting=[action(next_case=formatting.CASE_CAP_FIRST_WORD, trailing_space=' ')])], + [translation(formatting=[action(next_case=Case.CAP_FIRST_WORD, trailing_space=' ')])], ([action(text='Rest', word='rest', trailing_space=' ')],), [('b', 4), ('s', 'Rest')]), @@ -119,7 +120,7 @@ def test_starting_stroke(capitalized, attached, undo, do, prev, ([translation(formatting=[action(text_and_word='dare'), action(prev_attach=True, text='ing', word='daring', prev_replace='e')])], [translation(english='rest')], - [translation(formatting=[action(next_case=formatting.CASE_CAP_FIRST_WORD, + [translation(formatting=[action(next_case=Case.CAP_FIRST_WORD, trailing_space=' ')])], ([action(text='Rest', word='rest', trailing_space=' ')],), [('b', 6), ('s', 'Rest')]), @@ -239,72 +240,72 @@ def test_action(): lambda: ('{^} {.} hello {.} {#ALT_L(Grave)}{^ ^}', action(), [action(prev_attach=True, text_and_word='', next_attach=True, orthography=False), - action(prev_attach=True, text_and_word='.', trailing_space=' ', next_case=formatting.CASE_CAP_FIRST_WORD), + action(prev_attach=True, text_and_word='.', trailing_space=' ', next_case=Case.CAP_FIRST_WORD), action(text='Hello', word='hello', trailing_space=' '), - action(prev_attach=True, text_and_word='.', trailing_space=' ', next_case=formatting.CASE_CAP_FIRST_WORD), - action(word='.', trailing_space=' ', combo='ALT_L(Grave)', next_case=formatting.CASE_CAP_FIRST_WORD), + action(prev_attach=True, text_and_word='.', trailing_space=' ', next_case=Case.CAP_FIRST_WORD), + action(word='.', trailing_space=' ', combo='ALT_L(Grave)', next_case=Case.CAP_FIRST_WORD), action(prev_attach=True, text=' ', word='', next_attach=True) ]), lambda: ('{-|}{>}{&a}{>}{&b}', action(), - [action(next_case=formatting.CASE_CAP_FIRST_WORD), - action(next_case=formatting.CASE_LOWER_FIRST_CHAR), + [action(next_case=Case.CAP_FIRST_WORD), + action(next_case=Case.LOWER_FIRST_CHAR), action(text_and_word='a', trailing_space=' ', glue=True), - action(next_case=formatting.CASE_LOWER_FIRST_CHAR, word='a', trailing_space=' ', glue=True), + action(next_case=Case.LOWER_FIRST_CHAR, word='a', trailing_space=' ', glue=True), action(prev_attach=True, text='b', word='ab', trailing_space=' ', glue=True), ]), lambda: ('{-|}{>}{&a}{>}{&b}', action(), - [action(next_case=formatting.CASE_CAP_FIRST_WORD), - action(next_case=formatting.CASE_LOWER_FIRST_CHAR), + [action(next_case=Case.CAP_FIRST_WORD), + action(next_case=Case.LOWER_FIRST_CHAR), action(text_and_word='a', trailing_space=' ', glue=True), - action(next_case=formatting.CASE_LOWER_FIRST_CHAR, word='a', trailing_space=' ', glue=True), + action(next_case=Case.LOWER_FIRST_CHAR, word='a', trailing_space=' ', glue=True), action(prev_attach=True, text='b', word='ab', trailing_space=' ', glue=True), ]), lambda: ('{-|} equip {^s}', action(), - [action(next_case=formatting.CASE_CAP_FIRST_WORD), + [action(next_case=Case.CAP_FIRST_WORD), action(text='Equip', word='equip', trailing_space=' '), action(prev_attach=True, text='s', trailing_space=' ', word='equips'), ]), lambda: ('{-|} equip {^ed}', action(), - [action(next_case=formatting.CASE_CAP_FIRST_WORD), + [action(next_case=Case.CAP_FIRST_WORD), action(text='Equip', word='equip', trailing_space=' '), action(prev_attach=True, text='ped', trailing_space=' ', word='equipped'), ]), lambda: ('{>} Equip', action(), - [action(next_case=formatting.CASE_LOWER_FIRST_CHAR), + [action(next_case=Case.LOWER_FIRST_CHAR), action(text='equip', word='Equip', trailing_space=' ') ]), lambda: ('{>} equip', action(), - [action(next_case=formatting.CASE_LOWER_FIRST_CHAR), + [action(next_case=Case.LOWER_FIRST_CHAR), action(text_and_word='equip', trailing_space=' ') ]), lambda: ('{<} equip', action(), - [action(next_case=formatting.CASE_UPPER_FIRST_WORD), + [action(next_case=Case.UPPER_FIRST_WORD), action(text='EQUIP', word='equip', trailing_space=' ', upper_carry=True) ]), lambda: ('{<} EQUIP', action(), - [action(next_case=formatting.CASE_UPPER_FIRST_WORD), + [action(next_case=Case.UPPER_FIRST_WORD), action(text_and_word='EQUIP', trailing_space=' ', upper_carry=True) ]), lambda: ('{<} equip {^ed}', action(), - [action(next_case=formatting.CASE_UPPER_FIRST_WORD), + [action(next_case=Case.UPPER_FIRST_WORD), action(text='EQUIP', word='equip', trailing_space=' ', upper_carry=True), action(prev_attach=True, text='PED', trailing_space=' ', word='equipped', upper_carry=True) ]), @@ -419,47 +420,47 @@ def test_action(): lambda: ('{-|}{^|~|^}', action(), - [action(next_case=formatting.CASE_CAP_FIRST_WORD), + [action(next_case=Case.CAP_FIRST_WORD), action(prev_attach=True, text_and_word='|~|', next_attach=True), ]), lambda: ('{-|}{~|\'^}cause', action(), - [action(next_case=formatting.CASE_CAP_FIRST_WORD), - action(text_and_word='\'', next_attach=True, next_case=formatting.CASE_CAP_FIRST_WORD), + [action(next_case=Case.CAP_FIRST_WORD), + action(text_and_word='\'', next_attach=True, next_case=Case.CAP_FIRST_WORD), action(prev_attach=True, text='Cause', trailing_space=' ', word='cause'), ]), lambda: ('{.}{~|\'^}cuz', action(), - [action(prev_attach=True, text_and_word='.', trailing_space=' ', next_case=formatting.CASE_CAP_FIRST_WORD), - action(text_and_word='\'', next_attach=True, next_case=formatting.CASE_CAP_FIRST_WORD), + [action(prev_attach=True, text_and_word='.', trailing_space=' ', next_case=Case.CAP_FIRST_WORD), + action(text_and_word='\'', next_attach=True, next_case=Case.CAP_FIRST_WORD), action(prev_attach=True, text='Cuz', trailing_space=' ', word='cuz'), ]), lambda: ('{.}{~|\'^}cause', action(), - [action(prev_attach=True, text_and_word='.', trailing_space=' ', next_case=formatting.CASE_CAP_FIRST_WORD), - action(text_and_word='\'', next_attach=True, next_case=formatting.CASE_CAP_FIRST_WORD), + [action(prev_attach=True, text_and_word='.', trailing_space=' ', next_case=Case.CAP_FIRST_WORD), + action(text_and_word='\'', next_attach=True, next_case=Case.CAP_FIRST_WORD), action(prev_attach=True, text='Cause', trailing_space=' ', word='cause'), ]), lambda: ('{.}{^~|\"}heyyo', action(), - [action(prev_attach=True, text_and_word='.', trailing_space=' ', next_case=formatting.CASE_CAP_FIRST_WORD), - action(prev_attach=True, text_and_word='"', trailing_space=' ', next_case=formatting.CASE_CAP_FIRST_WORD), + [action(prev_attach=True, text_and_word='.', trailing_space=' ', next_case=Case.CAP_FIRST_WORD), + action(prev_attach=True, text_and_word='"', trailing_space=' ', next_case=Case.CAP_FIRST_WORD), action(text='Heyyo', trailing_space=' ', word='heyyo'), ]), lambda: ('{.}{^~|^}zshrc', action(), - [action(prev_attach=True, text_and_word='.', trailing_space=' ', next_case=formatting.CASE_CAP_FIRST_WORD), - action(prev_attach=True, text_and_word='', next_attach=True, next_case=formatting.CASE_CAP_FIRST_WORD), + [action(prev_attach=True, text_and_word='.', trailing_space=' ', next_case=Case.CAP_FIRST_WORD), + action(prev_attach=True, text_and_word='', next_attach=True, next_case=Case.CAP_FIRST_WORD), action(prev_attach=True, text='Zshrc', trailing_space=' ', word='zshrc')]), lambda: ('{.}', action(), - [action(prev_attach=True, text_and_word='.', trailing_space=' ', next_case=formatting.CASE_CAP_FIRST_WORD)] + [action(prev_attach=True, text_and_word='.', trailing_space=' ', next_case=Case.CAP_FIRST_WORD)] ), lambda: @@ -580,27 +581,27 @@ def test_raw_to_actions(stroke, last_action, expected): lambda: ('{.}', action(prev_attach=True, word='test', trailing_space=' '), - action(prev_attach=True, text_and_word='.', trailing_space=' ', next_case=formatting.CASE_CAP_FIRST_WORD)), + action(prev_attach=True, text_and_word='.', trailing_space=' ', next_case=Case.CAP_FIRST_WORD)), lambda: ('{?}', action(text_and_word='test', trailing_space=' '), - action(prev_attach=True, text_and_word='?', trailing_space=' ', next_case=formatting.CASE_CAP_FIRST_WORD)), + action(prev_attach=True, text_and_word='?', trailing_space=' ', next_case=Case.CAP_FIRST_WORD)), lambda: ('{!}', action(text_and_word='test', trailing_space=' '), - action(prev_attach=True, text_and_word='!', trailing_space=' ', next_case=formatting.CASE_CAP_FIRST_WORD)), + action(prev_attach=True, text_and_word='!', trailing_space=' ', next_case=Case.CAP_FIRST_WORD)), lambda: ('{-|}', action(text_and_word='test', trailing_space=' '), - action(next_case=formatting.CASE_CAP_FIRST_WORD, word='test', trailing_space=' ')), + action(next_case=Case.CAP_FIRST_WORD, word='test', trailing_space=' ')), lambda: ('{>}', action(text_and_word='test', trailing_space=' '), - action(next_case=formatting.CASE_LOWER_FIRST_CHAR, word='test', trailing_space=' ')), + action(next_case=Case.LOWER_FIRST_CHAR, word='test', trailing_space=' ')), lambda: ('{<}', action(text_and_word='test', trailing_space=' '), - action(next_case=formatting.CASE_UPPER_FIRST_WORD, word='test', trailing_space=' ')), + action(next_case=Case.UPPER_FIRST_WORD, word='test', trailing_space=' ')), lambda: ('{*-|}', action(text_and_word='test', trailing_space=' '), @@ -660,7 +661,7 @@ def test_raw_to_actions(stroke, last_action, expected): action(prev_attach=True, text_and_word='text', trailing_space=' ')), lambda: - ('text', action(text_and_word='test', trailing_space=' ', next_case=formatting.CASE_CAP_FIRST_WORD), + ('text', action(text_and_word='test', trailing_space=' ', next_case=Case.CAP_FIRST_WORD), action(text='Text', trailing_space=' ', word='text')), lambda: @@ -670,19 +671,19 @@ def test_raw_to_actions(stroke, last_action, expected): lambda: ('some text', action(text_and_word='test', trailing_space=' ', - case=formatting.CASE_TITLE, + case=Case.TITLE, space_char=''), action(text='SomeText', word='text', - case=formatting.CASE_TITLE, + case=Case.TITLE, space_char='')), lambda: ('some text', action(text_and_word='test', trailing_space=' ', # This is camel case - case=formatting.CASE_TITLE, - space_char='', next_case=formatting.CASE_LOWER_FIRST_CHAR), + case=Case.TITLE, + space_char='', next_case=Case.LOWER_FIRST_CHAR), action(text='someText', word='text', - case=formatting.CASE_TITLE, + case=Case.TITLE, space_char='')), lambda: @@ -690,24 +691,24 @@ def test_raw_to_actions(stroke, last_action, expected): action(text='some_text', trailing_space='_', word='text', space_char='_')), lambda: - ('some text', action(text_and_word='test', trailing_space=' ', case=formatting.CASE_UPPER), - action(text='SOME TEXT', trailing_space=' ', word='text', case=formatting.CASE_UPPER)), + ('some text', action(text_and_word='test', trailing_space=' ', case=Case.UPPER), + action(text='SOME TEXT', trailing_space=' ', word='text', case=Case.UPPER)), lambda: - ('sOme TexT', action(text_and_word='test', trailing_space=' ', case=formatting.CASE_LOWER), - action(text='some text', trailing_space=' ', word='TexT', case=formatting.CASE_LOWER)), + ('sOme TexT', action(text_and_word='test', trailing_space=' ', case=Case.LOWER), + action(text='some text', trailing_space=' ', word='TexT', case=Case.LOWER)), lambda: - ('sOme TexT', action(text_and_word='test', trailing_space=' ', case=formatting.CASE_TITLE), - action(text='Some Text', trailing_space=' ', word='TexT', case=formatting.CASE_TITLE)), + ('sOme TexT', action(text_and_word='test', trailing_space=' ', case=Case.TITLE), + action(text='Some Text', trailing_space=' ', word='TexT', case=Case.TITLE)), lambda: ('{MODE:CAPS}', action(text_and_word='test', trailing_space=' '), - action(word='test', trailing_space=' ', case=formatting.CASE_UPPER)), + action(word='test', trailing_space=' ', case=Case.UPPER)), lambda: ('{MODE:LOWER}', action(text_and_word='test', trailing_space=' '), - action(word='test', trailing_space=' ', case=formatting.CASE_LOWER)), + action(word='test', trailing_space=' ', case=Case.LOWER)), ) @@ -729,20 +730,20 @@ def test_atom_to_action(atom, last_action, expected): # CAPS: Uppercase lambda: ('CAPS', action(), - action(case=formatting.CASE_UPPER)), + action(case=Case.UPPER)), # LOWER: Lowercase lambda: ('LOWER', action(), - action(case=formatting.CASE_LOWER)), + action(case=Case.LOWER)), # TITLE: Titlecase lambda: ('TITLE', action(), - action(case=formatting.CASE_TITLE)), + action(case=Case.TITLE)), # CAMEL: Titlecase without space lambda: ('CAMEL', action(), - action(case=formatting.CASE_TITLE, space_char='', - next_case=formatting.CASE_LOWER_FIRST_CHAR)), + action(case=Case.TITLE, space_char='', + next_case=Case.LOWER_FIRST_CHAR)), # SNAKE: Underscore space lambda: ('SNAKE', action(), @@ -753,7 +754,7 @@ def test_atom_to_action(atom, last_action, expected): action()), # RESET_CASE: No case lambda: - ('RESET_CASE', action(case=formatting.CASE_UPPER), + ('RESET_CASE', action(case=Case.UPPER), action()), # SET_SPACE:xy: Set space to xy lambda: @@ -776,7 +777,7 @@ def test_meta_mode(meta, last_action, expected): last_action_normal = action() -last_action_capitalized = action(next_case=formatting.CASE_CAP_FIRST_WORD) +last_action_capitalized = action(next_case=Case.CAP_FIRST_WORD) last_action_attached = action(next_attach=True) META_CARRY_CAPITALIZE_TESTS = ( @@ -810,13 +811,13 @@ def test_meta_mode(meta, last_action, expected): # Verify capitalize carry. lambda: ('^~|^', last_action_capitalized, - (action(next_case=formatting.CASE_CAP_FIRST_WORD, text_and_word='', prev_attach=True, next_attach=True))), + (action(next_case=Case.CAP_FIRST_WORD, text_and_word='', prev_attach=True, next_attach=True))), lambda: ('^~|aset^', last_action_capitalized, - (action(next_case=formatting.CASE_CAP_FIRST_WORD, prev_attach=True, next_attach=True, text='Aset', word='aset'))), + (action(next_case=Case.CAP_FIRST_WORD, prev_attach=True, next_attach=True, text='Aset', word='aset'))), lambda: ('~|aset', last_action_capitalized, - (action(next_case=formatting.CASE_CAP_FIRST_WORD, text='Aset', trailing_space=' ', word='aset'))), + (action(next_case=Case.CAP_FIRST_WORD, text='Aset', trailing_space=' ', word='aset'))), # Verify 'next_attach' flag overriding. lambda: @@ -847,18 +848,18 @@ def _apply_case_tests(): lambda: (test, None, False, test), lambda: (test, None, True, test), # TITLE - lambda: (test, formatting.CASE_TITLE, False, ' Some Test '), + lambda: (test, Case.TITLE, False, ' Some Test '), # TITLE will not affect appended output - lambda: (test, formatting.CASE_TITLE, True, ' some test '), - lambda: (test2, formatting.CASE_TITLE, True, 'test Me'), + lambda: (test, Case.TITLE, True, ' some test '), + lambda: (test2, Case.TITLE, True, 'test Me'), # LOWER - lambda: (test, formatting.CASE_LOWER, False, ' some test '), - lambda: (test3, formatting.CASE_LOWER, False, ' some test '), - lambda: (test2, formatting.CASE_LOWER, True, 'test me'), + lambda: (test, Case.LOWER, False, ' some test '), + lambda: (test3, Case.LOWER, False, ' some test '), + lambda: (test2, Case.LOWER, True, 'test me'), # UPPER - lambda: (test.upper(), formatting.CASE_UPPER, False, ' SOME TEST '), - lambda: (test3, formatting.CASE_UPPER, False, ' SOME TEST '), - lambda: (test2, formatting.CASE_UPPER, True, 'TEST ME'), + lambda: (test.upper(), Case.UPPER, False, ' SOME TEST '), + lambda: (test3, Case.UPPER, False, ' SOME TEST '), + lambda: (test2, Case.UPPER, True, 'TEST ME'), ) @parametrize(_apply_case_tests()) @@ -1076,7 +1077,7 @@ def format(self, text): lambda: (['Luca', '{-|}', 'mela'], [action(text='Mela', trailing_space=' ', word='mela'), - action(word='Luca', trailing_space=' ', next_case=formatting.CASE_CAP_FIRST_WORD), + action(word='Luca', trailing_space=' ', next_case=Case.CAP_FIRST_WORD), action(text_and_word='Luca', trailing_space=' ')]), )