Esempio n. 1
0
 def test_that_unknown_unicode_characters_raise_exception(self):
     # you know that Santa Clause character? Seriously, if you don't know it,
     # you should have a look. LaTeX does indeed not have command for this
     # (2016, one never knows)
     santa = chr(127877)
     with self.assertRaises(document.DocumentSerializationException):
         document.escape_unicode_in_formulas(santa)
Esempio n. 2
0
 def test_that_mathmode_and_textmode_are_treated_differently(self):
     math = document.escape_unicode_in_formulas('ö')
     self.assertNotEqual(math, 'ö')
     text = document.escape_unicode_in_formulas('\\text{ö}')
     self.assertFalse('ö' in text)
     # check whether characters got transcribed differently; it's enough to
     # check one character of the generated sequence, they should differ
     self.assertNotEqual(math[:2], text[6:8])
Esempio n. 3
0
 def test_that_all_characters_are_preserved_when_no_replacements_happen(self):
     text = 'This is a \\text{test} mate.'
     self.assertEqual(document.escape_unicode_in_formulas(text), text)
     self.assertEqual(document.escape_unicode_in_formulas(text,
         replace_alphabeticals=False), text)
     text = 'But yeah but no' * 20 + ', oh my god!'
     self.assertEqual(document.escape_unicode_in_formulas(text), text)
     self.assertEqual(document.escape_unicode_in_formulas(text,
         replace_alphabeticals=False), text)
Esempio n. 4
0
    def test_that_everything_around_surrounded_character_is_preserved(self):
        text = 'This is a \\text{über} test. ;)'
        result = document.escape_unicode_in_formulas(text,
                replace_alphabeticals=True)
        ue_pos = text.index('ü')
        # text in front is unchanged
        self.assertEqual(result[:ue_pos], text[:ue_pos])
        # find b character, which is the start of the remaining string
        b_pos = result[ue_pos:].find('b') + ue_pos
        # check that text after umlaut matches
        self.assertEqual(result[b_pos:], text[ue_pos+1:])

        text = 'But yeah but no' * 20 + ', oh my god!ø'
        o_strok_pos = text.index('ø')
        res = document.escape_unicode_in_formulas(text)
        self.assertEqual(res[:o_strok_pos], text[:o_strok_pos])
Esempio n. 5
0
 def test_that_two_text_environments_preserve_all_characters(self):
     text = r'a\cdot b \text{equals} b\cdot c} \mbox{ is not equal } u^{v\cdot k}'
     self.assertEqual(document.escape_unicode_in_formulas(text), text)
Esempio n. 6
0
 def test_that_flag_to_preserve_alphas_is_passed_through(self):
     res = document.escape_unicode_in_formulas('\\text{ö}',
             replace_alphabeticals=False)
     self.assertEqual(res, '\\text{ö}')