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_str(self): self.assertEqual(str(self.value), to_str(str(self.value)))
def test_to_str_bytes(self): self.assertEqual('hello', to_str(b'hello'))
def test_to_str_str(self): self.assertEqual('hello', to_str('hello'))
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_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)