def test_end_to_end(self): n_file_path = os.path.join(self.tmp_dir, 'n_file') with open(n_file_path, 'w') as f: f.write('3') os.environ['LOCAL_N_FILE_PATH'] = n_file_path stdin = ['0\n', '1\n', '2\n'] # use local runner so that the file is actually sent somewhere mr_job = MRTowerOfPowers([ '-v', '--cleanup=NONE', '--n-file', n_file_path, '--runner=local' ]) self.assertEqual(len(mr_job.steps()), 3) mr_job.sandbox(stdin=stdin) with logger_disabled('mrjob.local'): with mr_job.make_runner() as runner: # make sure our file gets placed in the working dir self.assertIn(n_file_path, runner._working_dir_mgr.paths()) runner.run() output = set() for line in runner.stream_output(): _, value = mr_job.parse_output_line(line) output.add(value) self.assertEqual(set(output), set([0, 1, ((2**3)**3)**3]))
def test_end_to_end(self): n_file_path = os.path.join(self.tmp_dir, 'n_file') with open(n_file_path, 'w') as f: f.write('3') os.environ['LOCAL_N_FILE_PATH'] = n_file_path stdin = ['0\n', '1\n', '2\n'] mr_job = MRTowerOfPowers(['--no-conf', '-v', '--cleanup=NONE', '--n-file', n_file_path]) assert_equal(len(mr_job.steps()), 3) mr_job.sandbox(stdin=stdin) with mr_job.make_runner() as runner: assert isinstance(runner, LocalMRJobRunner) # make sure our file gets "uploaded" assert [fd for fd in runner._files if fd['path'] == n_file_path] runner.run() output = set() for line in runner.stream_output(): _, value = mr_job.parse_output_line(line) output.add(value) assert_equal(set(output), set([0, 1, ((2**3)**3)**3]))
def test_end_to_end(self): n_file_path = os.path.join(self.tmp_dir, "n_file") with open(n_file_path, "w") as f: f.write("3") os.environ["LOCAL_N_FILE_PATH"] = n_file_path stdin = ["0\n", "1\n", "2\n"] # use local runner so that the file is actually sent somewhere mr_job = MRTowerOfPowers(["-v", "--cleanup=NONE", "--n-file", n_file_path, "--runner=local"]) self.assertEqual(len(mr_job.steps()), 3) mr_job.sandbox(stdin=stdin) with logger_disabled("mrjob.local"): with mr_job.make_runner() as runner: # make sure our file gets placed in the working dir self.assertIn(n_file_path, runner._working_dir_mgr.paths()) runner.run() output = set() for line in runner.stream_output(): _, value = mr_job.parse_output_line(line) output.add(value) self.assertEqual(set(output), set([0, 1, ((2 ** 3) ** 3) ** 3]))
def test_end_to_end(self): n_file_path = os.path.join(self.tmp_dir, 'n_file') with open(n_file_path, 'w') as f: f.write('3') os.environ['LOCAL_N_FILE_PATH'] = n_file_path stdin = [b'0\n', b'1\n', b'2\n'] # use local runner so that the file is actually sent somewhere mr_job = MRTowerOfPowers( ['-v', '--cleanup=NONE', '--n-file', n_file_path, '--runner=local']) self.assertEqual(len(mr_job.steps()), 3) mr_job.sandbox(stdin=stdin) with logger_disabled('mrjob.local'): with mr_job.make_runner() as runner: # make sure our file gets placed in the working dir self.assertIn(n_file_path, runner._working_dir_mgr.paths()) runner.run() output = set() for line in runner.stream_output(): _, value = mr_job.parse_output_line(line) output.add(value) self.assertEqual(set(output), set([0, 1, ((2 ** 3) ** 3) ** 3]))
def test_end_to_end(self): n_file_path = os.path.join(self.tmp_dir, 'n_file') with open(n_file_path, 'w') as f: f.write('3') os.environ['LOCAL_N_FILE_PATH'] = n_file_path stdin = ['0\n', '1\n', '2\n'] mr_job = MRTowerOfPowers( ['--no-conf', '-v', '--cleanup=NONE', '--n-file', n_file_path]) assert_equal(len(mr_job.steps()), 3) mr_job.sandbox(stdin=stdin) with logger_disabled('mrjob.local'): with mr_job.make_runner() as runner: assert isinstance(runner, LocalMRJobRunner) # make sure our file gets "uploaded" assert [ fd for fd in runner._files if fd['path'] == n_file_path ] runner.run() output = set() for line in runner.stream_output(): _, value = mr_job.parse_output_line(line) output.add(value) assert_equal(set(output), set([0, 1, ((2**3)**3)**3]))