def test_to_str2(self):
     val = 'string'
     errors = 'strict'
     res = to_str(val)
     self.assertEqual(
         res,
         val.encode('utf8', errors=errors)
         if isinstance(val, unicode) else val)
Beispiel #2
0
 def test_to_str_else(self):
     val = "значение"
     result = to_str(val)
     self.assertTrue(isinstance(result, str))
Beispiel #3
0
 def test_to_str(self):
     val = u"val"
     result = to_str(val)
     self.assertTrue(isinstance(result, str))
Beispiel #4
0
 def test_to_str_str(self):
     self.assertEqual(str(self.value), to_str(str(self.value)))
Beispiel #5
0
 def test_to_str_bytes(self):
     self.assertEqual('hello', to_str(b'hello'))
Beispiel #6
0
 def test_to_str_str(self):
     self.assertEqual('hello', to_str('hello'))
Beispiel #7
0
 def test_to_str_bytes(self):
     self.assertEqual(str(self.value), to_str(str(self.value).encode()))
 def test_to_str2(self):
     val = 'string'
     errors='strict'
     res = to_str(val)
     self.assertEqual(res, val.encode('utf8', errors=errors) if isinstance(val, unicode) else val)
 def test_to_str_else(self):
     val = "значение"
     result = to_str(val)
     self.assertTrue(isinstance(result, str))
 def test_to_str(self):
     val = u"val"
     result = to_str(val)
     self.assertTrue(isinstance(result, str))
 def test_to_str_with_unicode_source(self):
     src = u'рщырыщрызtestkjlsa'
     assert isinstance(to_str(src), str)
 def test_to_str_with_str_source(self):
     src = 'testkjlsa'
     assert isinstance(to_str(src), str)