예제 #1
0
 def _get_template_variable(self, name: str) -> str:
     if name in self._template_variables:
         return self._template_variables[name]
     try:
         cache = _TEMPLATE_VARIABLES[name](self)
     except KeyError:
         # name[0] should always be %.
         lower_name = name[0] + french.lower_first_letter(name[1:])
         if lower_name not in _TEMPLATE_VARIABLES:
             logging.info('Wrong case in template variable "%s", cannot replace it.', name)
             cache = name
         else:
             # Recursion cannot run in a loop thanks to the test just before.
             cache = french.upper_first_letter(self._get_template_variable(lower_name))
     self._template_variables[name] = cache
     return cache
예제 #2
0
    def test_one_letter(self) -> None:
        """Only one letter."""

        sentence = french.upper_first_letter('t')
        self.assertEqual('T', sentence)
예제 #3
0
    def test_all_lowercase(self) -> None:
        """All upper case."""

        sentence = french.upper_first_letter('this is all lowercase')
        self.assertEqual('This is all lowercase', sentence)
예제 #4
0
    def test_all_uppercase(self) -> None:
        """All upper case."""

        sentence = french.upper_first_letter('THIS IS ALL UPPERCASE')
        self.assertEqual('THIS IS ALL UPPERCASE', sentence)
예제 #5
0
    def test_empty(self) -> None:
        """Empty string."""

        sentence = french.upper_first_letter('')
        self.assertEqual('', sentence)