def test_list(self): data = unicode2bytes([ u'foo', u'bar', ]) self.assertEqual(['foo', 'bar'], data) for item in data: self.assertTrue(isinstance(item, str))
def test_list(self): data = unicode2bytes([ u'foo', u'bar', ]) self.assertEqual(['foo', 'bar'], data) for item in data: self.assertTrue(isinstance(item, str))
def test_dict(self): data = unicode2bytes({ u'foo': u'bar', u'spam': u'eggs', }) self.assertEqual({'foo': 'bar', 'spam': 'eggs'}, data) for k, v in data.items(): self.assertTrue(isinstance(k, str)) self.assertTrue(isinstance(v, str))
def test_dict(self): data = unicode2bytes({ u'foo': u'bar', u'spam': u'eggs', }) self.assertEqual({'foo': 'bar', 'spam': 'eggs'}, data) for k, v in data.items(): self.assertTrue(isinstance(k, str)) self.assertTrue(isinstance(v, str))
def test_nested(self): data = unicode2bytes({ u'foo': { u'bar': [u'baz', u'qux'], }, }) self.assertEqual({'foo': {'bar': ['baz', 'qux']}}, data) self.assertTrue(isinstance(data.keys()[0], str)) self.assertTrue(isinstance(data['foo'].keys()[0], str)) for item in data['foo']['bar']: self.assertTrue(isinstance(item, str))
def test_nested(self): data = unicode2bytes({ u'foo': { u'bar': [u'baz', u'qux'], }, }) self.assertEqual({'foo': {'bar': ['baz', 'qux']}}, data) self.assertTrue(isinstance(data.keys()[0], str)) self.assertTrue(isinstance(data['foo'].keys()[0], str)) for item in data['foo']['bar']: self.assertTrue(isinstance(item, str))
def test_byte_string(self): self.assertEqual('foo', unicode2bytes('foo')) self.assertTrue(isinstance(unicode2bytes('foo'), str))
def test_byte_string(self): self.assertEqual('foo', unicode2bytes('foo')) self.assertTrue(isinstance(unicode2bytes('foo'), str))