本文整理汇总了Python中mrjob.job.MRJob.stdout方法的典型用法代码示例。如果您正苦于以下问题:Python MRJob.stdout方法的具体用法?Python MRJob.stdout怎么用?Python MRJob.stdout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mrjob.job.MRJob
的用法示例。
在下文中一共展示了MRJob.stdout方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_default
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import stdout [as 别名]
def test_default(self):
# test parsing JSON
mr_job = MRJob()
output = '0\t1\n"a"\t"b"\n'
mr_job.stdout = StringIO(output)
self.assertEqual(mr_job.parse_output(), [(0, 1), ('a', 'b')])
# verify that stdout is not cleared
self.assertEqual(mr_job.stdout.getvalue(), output)
示例2: test_protocol_instance
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import stdout [as 别名]
def test_protocol_instance(self):
# see if we can use the repr protocol
mr_job = MRJob()
output = "0\t1\n['a', 'b']\tset(['c', 'd'])\n"
mr_job.stdout = StringIO(output)
self.assertEqual(mr_job.parse_output(ReprProtocol()), [(0, 1), (["a", "b"], set(["c", "d"]))])
# verify that stdout is not cleared
self.assertEqual(mr_job.stdout.getvalue(), output)
示例3: test_parse_output
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import stdout [as 别名]
def test_parse_output(self):
# test parsing JSON
mr_job = MRJob()
output = b'0\t1\n"a"\t"b"\n'
mr_job.stdout = BytesIO(output)
with logger_disabled('mrjob.job'):
self.assertEqual(mr_job.parse_output(), [(0, 1), ('a', 'b')])
# verify that stdout is not cleared
self.assertEqual(mr_job.stdout.getvalue(), output)
示例4: test_deprecated_protocol_aliases
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import stdout [as 别名]
def test_deprecated_protocol_aliases(self):
# see if we can use the repr protocol
mr_job = MRJob()
output = "0\t1\n['a', 'b']\tset(['c', 'd'])\n"
mr_job.stdout = StringIO(output)
assert_equal(mr_job.parse_output('repr'),
[(0, 1), (['a', 'b'], set(['c', 'd']))])
# verify that stdout is not cleared
assert_equal(mr_job.stdout.getvalue(), output)
示例5: test_parse_output_with_protocol_instance
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import stdout [as 别名]
def test_parse_output_with_protocol_instance(self):
# see if we can use the repr protocol
mr_job = MRJob()
output = b"0\t1\n['a', 'b']\tset(['c', 'd'])\n"
mr_job.stdout = BytesIO(output)
with logger_disabled('mrjob.job'):
self.assertEqual(mr_job.parse_output(ReprProtocol()),
[(0, 1), (['a', 'b'], set(['c', 'd']))])
# verify that stdout is not cleared
self.assertEqual(mr_job.stdout.getvalue(), output)