def test_value_ending_with_padding(self):
        bytestring = b'Value ending with spaces   '
        assert 'Value ending with spaces' == convert_single_string(bytestring)
        assert 'Value ending with spaces' == convert_text(bytestring)

        bytestring = b'Values  \\with spaces   '
        assert ['Values', 'with spaces'] == convert_text(bytestring)

        bytestring = b'Value ending with zeros\0\0\0'
        assert 'Value ending with zeros' == convert_single_string(bytestring)
        assert 'Value ending with zeros' == convert_text(bytestring)

        bytestring = b'Values\0\0\\with zeros\0'
        assert ['Values', 'with zeros'] == convert_text(bytestring)
Пример #2
0
 def test_multi_value(self):
     bytestring = (b'Buc^J\xe9r\xf4me\\\x1b\x2d\x46'
                   b'\xc4\xe9\xef\xed\xf5\xf3\xe9\xef\xf2\\'
                   b'\x1b\x2d\x4C'
                   b'\xbb\xee\xda\x63\x65\xdc\xd1\x79\x70\xd3')
     encodings = ('latin_1', 'iso_ir_144', 'iso_ir_126')
     assert [u'Buc^Jérôme', u'Διονυσιος',
             u'Люкceмбypг'] == convert_text(bytestring, encodings)
 def test_multi_value(self):
     """Test that backslash is handled as value separator"""
     bytestring = (b'Buc^J\xe9r\xf4me\\\x1b\x2d\x46'
                   b'\xc4\xe9\xef\xed\xf5\xf3\xe9\xef\xf2\\'
                   b'\x1b\x2d\x4C'
                   b'\xbb\xee\xda\x63\x65\xdc\xd1\x79\x70\xd3')
     encodings = ('latin_1', 'iso_ir_144', 'iso_ir_126')
     assert ['Buc^Jérôme', 'Διονυσιος', 'Люкceмбypг'] == convert_text(
         bytestring, encodings)
Пример #4
0
 def test_multi_value(self):
     """Test that backslash is handled as value separator"""
     bytestring = (b'Buc^J\xe9r\xf4me\\\x1b\x2d\x46'
                   b'\xc4\xe9\xef\xed\xf5\xf3\xe9\xef\xf2\\'
                   b'\x1b\x2d\x4C'
                   b'\xbb\xee\xda\x63\x65\xdc\xd1\x79\x70\xd3')
     encodings = ('latin_1', 'iso_ir_144', 'iso_ir_126')
     assert [u'Buc^Jérôme', u'Διονυσιος', u'Люкceмбypг'] == convert_text(
         bytestring, encodings)
 def test_single_value(self):
     """Test that encoding can change inside a text string"""
     bytestring = (b'Dionysios is \x1b\x2d\x46'
                   b'\xc4\xe9\xef\xed\xf5\xf3\xe9\xef\xf2')
     encodings = ('latin_1', 'iso_ir_126')
     assert 'Dionysios is Διονυσιος' == convert_text(bytestring, encodings)
Пример #6
0
 def test_single_value(self):
     bytestring = (b'Dionysios is \x1b\x2d\x46'
                   b'\xc4\xe9\xef\xed\xf5\xf3\xe9\xef\xf2')
     encodings = ('latin_1', 'iso_ir_126')
     assert u'Dionysios is Διονυσιος' == convert_text(bytestring, encodings)
Пример #7
0
 def test_single_value(self):
     """Test that encoding can change inside a text string"""
     bytestring = (b'Dionysios is \x1b\x2d\x46'
                   b'\xc4\xe9\xef\xed\xf5\xf3\xe9\xef\xf2')
     encodings = ('latin_1', 'iso_ir_126')
     assert u'Dionysios is Διονυσιος' == convert_text(bytestring, encodings)