Ejemplo n.º 1
0
 def get_encoded_subject(subject):
     try:
         subject.encode('ascii')
     except UnicodeEncodeError:
         return encode(subject, encoding='b')
     else:
         return subject
 def test_auto_b_if_long_unsafe(self):
     self.assertEqual(_ew.encode('vi.vi.vi.vi.vi.', 'utf-8'),
                      '=?utf-8?b?dmkudmkudmkudmkudmku?=')
 def test_auto_b_if_enough_unsafe(self):
     self.assertEqual(_ew.encode('.....', 'utf-8'), '=?utf-8?b?Li4uLi4=?=')
 def test_auto_q_if_short_mostly_safe(self):
     self.assertEqual(_ew.encode('vi.', 'utf-8'), '=?utf-8?q?vi=2E?=')
 def test_auto_q(self):
     self.assertEqual(_ew.encode('foo', 'utf-8'), '=?utf-8?q?foo?=')
 def test_b(self):
     self.assertEqual(_ew.encode('foo', 'utf-8', 'b'), '=?utf-8?b?Zm9v?=')
 def test_auto_q(self):
     self.assertEqual(_ew.encode('foo', 'utf-8'), '=?utf-8?q?foo?=')
 def test_lang(self):
     self.assertEqual(_ew.encode('foo', lang='jive'),
                      '=?utf-8*jive?q?foo?=')
 def test_lang(self):
     self.assertEqual(_ew.encode('foo', lang='jive'), '=?utf-8*jive?q?foo?=')
Ejemplo n.º 10
0
 def test_utf8_default(self):
     self.assertEqual(_ew.encode('foo'), '=?utf-8?q?foo?=')
Ejemplo n.º 11
0
 def test_auto_q_if_long_mostly_safe(self):
     self.assertEqual(_ew.encode('vi vi vi.vi ', 'utf-8'),
                      '=?utf-8?q?vi_vi_vi=2Evi_?=')
Ejemplo n.º 12
0
 def test_auto_b_if_long_unsafe(self):
     self.assertEqual(_ew.encode('vi.vi.vi.vi.vi.', 'utf-8'),
                      '=?utf-8?b?dmkudmkudmkudmkudmku?=')
Ejemplo n.º 13
0
 def test_auto_b_if_enough_unsafe(self):
     self.assertEqual(_ew.encode('.....', 'utf-8'), '=?utf-8?b?Li4uLi4=?=')
Ejemplo n.º 14
0
 def test_auto_q_if_short_mostly_safe(self):
     self.assertEqual(_ew.encode('vi.', 'utf-8'), '=?utf-8?q?vi=2E?=')
 def test_auto_q_if_long_mostly_safe(self):
     self.assertEqual(_ew.encode('vi vi vi.vi ', 'utf-8'),
                      '=?utf-8?q?vi_vi_vi=2Evi_?=')
 def test_utf8_default(self):
     self.assertEqual(_ew.encode('foo'), '=?utf-8?q?foo?=')
Ejemplo n.º 17
0
 def test_unknown_8bit(self):
     self.assertEqual(_ew.encode('foo\uDCACbar', charset='unknown-8bit'),
                      '=?unknown-8bit?q?foo=ACbar?=')
 def test_unknown_8bit(self):
     self.assertEqual(_ew.encode('foo\uDCACbar', charset='unknown-8bit'),
                      '=?unknown-8bit?q?foo=ACbar?=')
Ejemplo n.º 19
0
 def test_b(self):
     self.assertEqual(_ew.encode('foo', 'utf-8', 'b'), '=?utf-8?b?Zm9v?=')