示例#1
0
 def test_extra_tabs(self):
     self.assertEqual(RawProtocol().write('foo', 'bar\tbaz'),
                      'foo\tbar\tbaz')
     self.assertEqual(RawProtocol().write('foo\tbar', 'baz'),
                      'foo\tbar\tbaz')
     self.assertEqual(RawProtocol().read('foo\tbar\tbaz'),
                      ('foo', 'bar\tbaz'))
示例#2
0
 def internal_protocol(self):
     if self.options.internal_format == 'json':
         return StandardJSONProtocol()
     elif self.options.internal_format == 'pickle':
         return PickleProtocol()
     elif self.options.internal_format == 'raw':
         return RawProtocol()
示例#3
0
    def pick_protocols(self, step_num, step_type):
        """Use RawProtocol to read output from the jar."""
        read, write = super(MRJarStepExample, self).pick_protocols(
            step_num, step_type)
        if (step_num, step_type) == (1, 'mapper'):
            read = RawProtocol().read

        return read, write
示例#4
0
    def test_no_tabs(self):
        self.assertEqual(RawProtocol().write('foo', None), 'foo')
        self.assertEqual(RawProtocol().write(None, 'foo'), 'foo')
        self.assertEqual(RawProtocol().read('foo'), ('foo', None))

        self.assertEqual(RawProtocol().write('', None), '')
        self.assertEqual(RawProtocol().write(None, None), '')
        self.assertEqual(RawProtocol().write(None, ''), '')
        self.assertEqual(RawProtocol().read(''), ('', None))
示例#5
0
 def test_no_strip(self):
     self.assertEqual(RawProtocol().read('foo\t \n\n'),
                      ('foo', ' \n\n'))
示例#6
0
 def test_round_trip(self):
     self.assertRoundTripOK(RawProtocol(), 'foo', 'bar')
     self.assertRoundTripOK(RawProtocol(), 'foo', None)
     self.assertRoundTripOK(RawProtocol(), 'foo', '')
     self.assertRoundTripOK(RawProtocol(), 'caf\xe9', '\xe90\c1a')