def test_from_string(self): from_unicode = BytesToken.from_string( six.text_type('0123456789abcdef')) from_bin = BytesToken.from_string(six.b('0123456789abcdef')) self.assertEqual(from_unicode, from_bin) self.assertIsInstance(from_unicode.value, six.binary_type) self.assertIsInstance(from_bin.value, six.binary_type)
def test_comparison_unicode(self): value = six.b('\'_-()"\xc2\xac') t0 = BytesToken(value) t1 = BytesToken.from_string('00') self.assertGreater(t0, t1) self.assertFalse(t0 < t1)
def test_comparison(self): tok = BytesToken.from_string(six.text_type('0123456789abcdef')) token_high_order = uint16_unpack(tok.value[0:2]) self.assertLess(BytesToken(uint16_pack(token_high_order - 1)), tok) self.assertGreater(BytesToken(uint16_pack(token_high_order + 1)), tok)
def test_from_string(self): from_unicode = BytesToken.from_string(six.text_type('0123456789abcdef')) from_bin = BytesToken.from_string(six.b('0123456789abcdef')) self.assertEqual(from_unicode, from_bin) self.assertIsInstance(from_unicode.value, six.binary_type) self.assertIsInstance(from_bin.value, six.binary_type)
def test_comparison_unicode(self): value = six.b('\'_-()"\xc2\xac') t0 = BytesToken(value) t1 = BytesToken.from_string('00') self.assertGreater(t0, t1) self.assertFalse(t0 < t1)
def test_comparison(self): tok = BytesToken.from_string(six.text_type('0123456789abcdef')) token_high_order = uint16_unpack(tok.value[0:2]) self.assertLess(BytesToken(uint16_pack(token_high_order - 1)), tok) self.assertGreater(BytesToken(uint16_pack(token_high_order + 1)), tok)