本文整理汇总了Python中tests.mr_os_walk_job.MROSWalkJob类的典型用法代码示例。如果您正苦于以下问题:Python MROSWalkJob类的具体用法?Python MROSWalkJob怎么用?Python MROSWalkJob使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MROSWalkJob类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_bad_setup_command
def test_bad_setup_command(self):
bar_path = os.path.join(self.tmp_dir, "bar")
baz_path = os.path.join(self.tmp_dir, "baz")
job = MROSWalkJob(
[
"-r",
"local",
"--setup",
"touch %s" % bar_path,
"--setup",
"false", # always "fails"
"--setup",
"touch %s" % baz_path,
"--cleanup-on-failure=ALL",
]
)
job.sandbox()
with job.make_runner() as r:
self.assertRaises(Exception, r.run)
# first command got run but not third one
self.assertTrue(os.path.exists(bar_path))
self.assertFalse(os.path.exists(baz_path))
开发者ID:irskep,项目名称:mrjob,代码行数:25,代码来源:test_runner.py
示例2: test_stdin_bypasses_wrapper_script
def test_stdin_bypasses_wrapper_script(self):
job = MROSWalkJob([
'-r', 'local',
'--setup', 'cat > stdin.txt',
])
job.sandbox(stdin=BytesIO(b'some input\n'))
# local mode doesn't currently pipe input into stdin
# (see issue #567), so this test would hang if it failed
def alarm_handler(*args, **kwargs):
raise Exception('Setup script stalled on stdin')
try:
self._old_alarm_handler = signal.signal(
signal.SIGALRM, alarm_handler)
signal.alarm(10)
with job.make_runner() as r:
r.run()
path_to_size = dict(job.parse_output_line(line)
for line in r.stream_output())
self.assertEqual(path_to_size.get('./stdin.txt'), 0)
# input gets passed through by identity mapper
self.assertEqual(path_to_size.get(None), 'some input')
finally:
signal.alarm(0)
signal.signal(signal.SIGALRM, self._old_alarm_handler)
开发者ID:anirudhreddy92,项目名称:mrjob,代码行数:30,代码来源:test_runner.py
示例3: test_setup_command
def test_setup_command(self):
job = MROSWalkJob(["-r", "local", "--setup", "touch bar"])
job.sandbox()
with job.make_runner() as r:
r.run()
path_to_size = dict(job.parse_output_line(line) for line in r.stream_output())
self.assertIn("./bar", path_to_size)
开发者ID:irskep,项目名称:mrjob,代码行数:10,代码来源:test_runner.py
示例4: test_setup_script
def test_setup_script(self):
job = MROSWalkJob(["-r", "local", "--setup", self.foo_sh + "#"])
job.sandbox()
with job.make_runner() as r:
r.run()
path_to_size = dict(job.parse_output_line(line) for line in r.stream_output())
self.assertEqual(path_to_size.get("./foo.sh"), self.foo_sh_size)
self.assertIn("./foo.sh-made-this", path_to_size)
开发者ID:irskep,项目名称:mrjob,代码行数:11,代码来源:test_runner.py
示例5: test_file_upload
def test_file_upload(self):
job = MROSWalkJob(["-r", "local", "--file", self.foo_sh, "--file", self.foo_sh + "#bar.sh"])
job.sandbox()
with job.make_runner() as r:
r.run()
path_to_size = dict(job.parse_output_line(line) for line in r.stream_output())
self.assertEqual(path_to_size.get("./foo.sh"), self.foo_sh_size)
self.assertEqual(path_to_size.get("./bar.sh"), self.foo_sh_size)
开发者ID:irskep,项目名称:mrjob,代码行数:11,代码来源:test_runner.py
示例6: test_archive_upload
def test_archive_upload(self):
job = MROSWalkJob(["-r", "local", "--archive", self.foo_tar_gz, "--archive", self.foo_tar_gz + "#foo"])
job.sandbox()
with job.make_runner() as r:
r.run()
path_to_size = dict(job.parse_output_line(line) for line in r.stream_output())
self.assertEqual(path_to_size.get("./foo.tar.gz/foo.py"), self.foo_py_size)
self.assertEqual(path_to_size.get("./foo/foo.py"), self.foo_py_size)
开发者ID:hophacker,项目名称:mrjob,代码行数:11,代码来源:test_runner.py
示例7: test_python_archive
def test_python_archive(self):
job = MROSWalkJob(["-r", "local", "--setup", "export PYTHONPATH=%s#/:$PYTHONPATH" % self.foo_tar_gz])
job.sandbox()
with job.make_runner() as r:
r.run()
path_to_size = dict(job.parse_output_line(line) for line in r.stream_output())
# foo.py should be there, and getsize() should be patched to return
# double the number of bytes
self.assertEqual(path_to_size.get("./foo.tar.gz/foo.py"), self.foo_py_size * 2)
开发者ID:irskep,项目名称:mrjob,代码行数:12,代码来源:test_runner.py
示例8: test_setup_command
def test_setup_command(self):
job = MROSWalkJob(
['-r', 'local',
'--setup', 'touch bar'])
job.sandbox()
with job.make_runner() as r:
r.run()
path_to_size = dict(job.parse_output_line(line)
for line in r.stream_output())
self.assertIn('./bar', path_to_size)
开发者ID:anirudhreddy92,项目名称:mrjob,代码行数:13,代码来源:test_runner.py
示例9: test_setup_command
def test_setup_command(self):
job = MROSWalkJob(
['-r', 'spark',
'--spark-master', _LOCAL_CLUSTER_MASTER,
'--setup', 'touch bar'])
job.sandbox()
with job.make_runner() as r:
r.run()
path_to_size = dict(job.parse_output(r.cat_output()))
self.assertIn('./bar', path_to_size)
开发者ID:Yelp,项目名称:mrjob,代码行数:13,代码来源:test_runner.py
示例10: test_setup_script
def test_setup_script(self):
job = MROSWalkJob(
['-r', 'local',
'--setup', self.foo_sh + '#'])
job.sandbox()
with job.make_runner() as r:
r.run()
path_to_size = dict(job.parse_output_line(line)
for line in r.stream_output())
self.assertEqual(path_to_size.get('./foo.sh'), self.foo_sh_size)
self.assertIn('./foo.sh-made-this', path_to_size)
开发者ID:anirudhreddy92,项目名称:mrjob,代码行数:14,代码来源:test_runner.py
示例11: test_file_upload
def test_file_upload(self):
job = MROSWalkJob(['-r', 'local',
'--file', self.foo_sh,
'--file', self.foo_sh + '#bar.sh',
])
job.sandbox()
with job.make_runner() as r:
r.run()
path_to_size = dict(job.parse_output_line(line)
for line in r.stream_output())
self.assertEqual(path_to_size.get('./foo.sh'), self.foo_sh_size)
self.assertEqual(path_to_size.get('./bar.sh'), self.foo_sh_size)
开发者ID:anirudhreddy92,项目名称:mrjob,代码行数:15,代码来源:test_runner.py
示例12: test_deprecated_python_archive_option
def test_deprecated_python_archive_option(self):
job = MROSWalkJob(
['-r', 'local',
'--python-archive', self.foo_tar_gz])
job.sandbox()
with job.make_runner() as r:
r.run()
path_to_size = dict(job.parse_output_line(line)
for line in r.stream_output())
# foo.py should be there, and getsize() should be patched to return
# double the number of bytes
self.assertEqual(path_to_size.get('./foo.tar.gz/foo.py'),
self.foo_py_size * 2)
开发者ID:anirudhreddy92,项目名称:mrjob,代码行数:16,代码来源:test_runner.py
示例13: test_wrapper_script_only_writes_to_stderr
def test_wrapper_script_only_writes_to_stderr(self):
job = MROSWalkJob(["-r", "local", "--setup", "echo stray output"])
job.sandbox()
with no_handlers_for_logger("mrjob.local"):
stderr = StringIO()
log_to_stream("mrjob.local", stderr, debug=True)
with job.make_runner() as r:
r.run()
output = b"".join(r.stream_output())
# stray ouput should be in stderr, not the job's output
self.assertIn("stray output", stderr.getvalue())
self.assertNotIn(b"stray output", output)
开发者ID:irskep,项目名称:mrjob,代码行数:16,代码来源:test_runner.py
示例14: test_archive_upload
def test_archive_upload(self):
job = MROSWalkJob(['--runner=local', '--no-bootstrap-mrjob',
'--archive', self.foo_tar_gz,
'--archive', self.foo_tar_gz + '#foo',
])
job.sandbox()
with job.make_runner() as r:
r.run()
path_to_size = dict(job.parse_output_line(line)
for line in r.stream_output())
self.assertEqual(path_to_size.get('./foo.tar.gz/foo.py'),
self.foo_py_size)
self.assertEqual(path_to_size.get('./foo/foo.py'),
self.foo_py_size)
开发者ID:SeanOC,项目名称:mrjob,代码行数:17,代码来源:test_local.py
示例15: test_bad_setup_command
def test_bad_setup_command(self):
bar_path = os.path.join(self.tmp_dir, 'bar')
baz_path = os.path.join(self.tmp_dir, 'baz')
job = MROSWalkJob([
'-r', 'local',
'--setup', 'touch %s' % bar_path,
'--setup', 'false', # always "fails"
'--setup', 'touch %s' % baz_path,
])
job.sandbox()
with job.make_runner() as r:
self.assertRaises(Exception, r.run)
# first command got run but not third one
self.assertTrue(os.path.exists(bar_path))
self.assertFalse(os.path.exists(baz_path))
开发者ID:Asana,项目名称:mrjob,代码行数:18,代码来源:test_runner.py
示例16: test_wrapper_script_only_writes_to_stderr
def test_wrapper_script_only_writes_to_stderr(self):
job = MROSWalkJob([
'-r', 'local',
'--setup', 'echo stray output',
])
job.sandbox()
with no_handlers_for_logger('mrjob.local'):
stderr = StringIO()
log_to_stream('mrjob.local', stderr, debug=True)
with job.make_runner() as r:
r.run()
output = b''.join(r.stream_output())
# stray ouput should be in stderr, not the job's output
self.assertIn('stray output', stderr.getvalue())
self.assertNotIn(b'stray output', output)
开发者ID:anirudhreddy92,项目名称:mrjob,代码行数:19,代码来源:test_runner.py
注:本文中的tests.mr_os_walk_job.MROSWalkJob类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论