Example #1
0
 def test_extra_tabs(self):
     self.assertEqual(TextProtocol().write(u'foo', u'bar\tbaz'),
                      b'foo\tbar\tbaz')
     self.assertEqual(TextProtocol().write(u'foo\tbar', u'baz'),
                      b'foo\tbar\tbaz')
     self.assertEqual(TextProtocol().read(b'foo\tbar\tbaz'),
                      (u'foo', u'bar\tbaz'))
Example #2
0
    def test_no_tabs(self):
        self.assertEqual(TextProtocol().write(u'foo', None), b'foo')
        self.assertEqual(TextProtocol().write(None, u'foo'), b'foo')
        self.assertEqual(TextProtocol().read(b'foo'), (u'foo', None))

        self.assertEqual(TextProtocol().write(u'', None), b'')
        self.assertEqual(TextProtocol().write(None, None), b'')
        self.assertEqual(TextProtocol().write(None, u''), b'')
        self.assertEqual(TextProtocol().read(b''), (u'', None))
Example #3
0
 def test_latin_1_fallback(self):
     # we fall back to latin-1 for the whole line, not individual fields
     self.assertEqual(TextProtocol().read(b'caf\xe9\tol\xc3\xa9'),
                      (u'caf\xe9', u'ol\xc3\xa9'))
Example #4
0
 def test_utf_8(self):
     self.assertEqual(TextProtocol().read(b'caf\xc3\xa9\tol\xc3\xa9'),
                      (u'caf\xe9', u'ol\xe9'))
Example #5
0
 def test_no_strip(self):
     self.assertEqual(TextProtocol().read(b'foo\t \n\n'),
                      (u'foo', u' \n\n'))
Example #6
0
 def test_round_trip(self):
     self.assertRoundTripOK(TextProtocol(), u'foo', u'bar')
     self.assertRoundTripOK(TextProtocol(), u'foo', None)
     self.assertRoundTripOK(TextProtocol(), u'foo', u'')
     self.assertRoundTripOK(TextProtocol(), u'caf\xe9', u'\Xe90\c1a')