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'))
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()
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
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))
def test_no_strip(self): self.assertEqual(RawProtocol().read('foo\t \n\n'), ('foo', ' \n\n'))
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')