def test_parse_padded_center(self): s = String("foo", 10, padchar=six.b("X"), paddir="center") self.assertEqual(s.parse(six.b("XXhelloXXX")), six.b("hello"))
def test_parse(self): s = String("foo", 5) self.assertEqual(s.parse(six.b("hello")), six.b("hello"))
def test_parse(self): s = String("foo", 5) self.assertEqual(s.parse(six.b("hello")), six.b("hello"))
def test_parse_utf8(self): s = String("foo", 12, encoding="utf8") self.assertEqual(s.parse(six.b("hello joh\xd4\x83n")), six.u("hello joh\u0503n"))
def test_parse_utf8(self): s = String("foo", 12, encoding="utf8") self.assertEqual(s.parse(six.b("hello joh\xd4\x83n")), six.u("hello joh\u0503n"))
def test_parse_padded_center(self): s = String("foo", 10, padchar=six.b("X"), paddir="center") self.assertEqual(s.parse(six.b("XXhelloXXX")), six.b("hello"))
def test_parse(self): s = String("foo", 5) self.assertEqual(s.parse(b"hello"), b"hello")
def test_parse_padded_center(self): s = String("foo", 10, padchar=b"X", paddir="center") self.assertEqual(s.parse(b"XXhelloXXX"), b"hello")
def test_parse_padded_left(self): s = String("foo", 10, padchar=b"X", paddir="left") self.assertEqual(s.parse(b"XXXXXhello"), b"hello")
def test_parse_padded(self): s = String("foo", 10, padchar=b"X", paddir="right") self.assertEqual(s.parse(b"helloXXXXX"), b"hello")
def test_parse_utf8(self): s = String("s", 12, encoding="utf8") self.assertEqual(s.parse(b"hello joh\xd4\x83n"), u"hello joh\u0503n")