Пример #1
0
 def test_conf_file(self):
     wd = tempfile.mkdtemp(prefix="pydoop_")
     conf_file = os.path.join(wd, "pydoop.conf")
     args_kv = (
         ("--pretend", None),
         ("--mrv2", None),
         ("--input-format", "mapreduce.lib.input.TextInputFormat"),
         ("--output-format", "mapreduce.lib.input.TextOutputFormat"),
         ("--num-reducers", 10),
         ("--python-zip", "allmymodules.zip"),
     )
     try:
         with open(conf_file, "w") as cf:
             d = "".join(["{}\n{}\n".format(k, v) if v is not None else "{}\n".format(k) for (k, v) in args_kv])
             cf.write(d)
         parser = app.make_parser()
         parser.format_help = nop
         module = "mymod1.mod2.mod3"
         ainput = "input"
         aoutput = "output"
         argv = ["submit", module, ainput, aoutput, "@" + conf_file]
         [args, unknown] = parser.parse_known_args(argv)
         self.assertEqual(args.module, module)
         self.assertEqual(args.input, ainput)
         self.assertEqual(args.output, aoutput)
         self.assertEqual(len(unknown), 0)
         self._check_args(args, args_kv)
     finally:
         shutil.rmtree(wd)
Пример #2
0
 def test_conf_file(self):
     wd = tempfile.mkdtemp(prefix='pydoop_')
     conf_file = os.path.join(wd, 'pydoop.conf')
     args_kv = (("--pretend", None),
                ("--mrv2", None),
                ("--input-format", 'mapreduce.lib.input.TextInputFormat'),
                ("--output-format", 'mapreduce.lib.input.TextOutputFormat'),
                ("--num-reducers", 10),
                ("--python-zip", 'allmymodules.zip'),
                )
     try:
         with open(conf_file, 'w') as cf:
             d = ''.join(['{}\n{}\n'.format(k, v)
                          if v is not None else '{}\n'.format(k)
                          for (k, v) in args_kv])
             cf.write(d)
         parser = app.make_parser()
         parser.format_help = nop
         module = 'mymod1.mod2.mod3'
         ainput = 'input'
         aoutput = 'output'
         argv = ['submit', module, ainput, aoutput, '@' + conf_file]
         [args, unknown] = parser.parse_known_args(argv)
         self.assertEqual(args.module, module)
         self.assertEqual(args.input, ainput)
         self.assertEqual(args.output, aoutput)
         self.assertEqual(len(unknown), 0)
         self._check_args(args, args_kv)
     finally:
         shutil.rmtree(wd)
Пример #3
0
 def test_conf_file(self):
     wd = tempfile.mkdtemp(prefix='pydoop_')
     conf_file = os.path.join(wd, 'pydoop.conf')
     args_kv = (
         ("--pretend", None),
         ("--mrv2", None),
         ("--input-format", 'mapreduce.lib.input.TextInputFormat'),
         ("--output-format", 'mapreduce.lib.input.TextOutputFormat'),
         ("--num-reducers", 10),
         ("--python-zip", 'allmymodules.zip'),
     )
     try:
         with open(conf_file, 'w') as cf:
             d = ''.join([
                 '{}\n{}\n'.format(k, v)
                 if v is not None else '{}\n'.format(k)
                 for (k, v) in args_kv
             ])
             cf.write(d)
         parser = app.make_parser()
         parser.format_help = nop
         module = 'mymod1.mod2.mod3'
         ainput = 'input'
         aoutput = 'output'
         argv = ['submit', module, ainput, aoutput, '@' + conf_file]
         [args, unknown] = parser.parse_known_args(argv)
         self.assertEqual(args.module, module)
         self.assertEqual(args.input, ainput)
         self.assertEqual(args.output, aoutput)
         self.assertEqual(len(unknown), 0)
         self._check_args(args, args_kv)
     finally:
         shutil.rmtree(wd)
Пример #4
0
 def test_empty_param(self):
     parser = app.make_parser()
     parser.format_help = nop
     program = "program"
     ainput = "input"
     aoutput = "output"
     argv = ["submit", "--module", "", program, ainput, aoutput]
     [args, unknown] = parser.parse_known_args(argv)
     self.assertEqual(args.module, "")
Пример #5
0
 def test_empty_param(self):
     parser = app.make_parser()
     parser.format_help = nop
     program = 'program'
     ainput = 'input'
     aoutput = 'output'
     argv = ['submit', '--module', '', program, ainput, aoutput]
     [args, unknown] = parser.parse_known_args(argv)
     self.assertEqual(args.module, '')
Пример #6
0
 def test_empty_param(self):
     parser = app.make_parser()
     parser.format_help = nop
     program = 'program'
     ainput = 'input'
     aoutput = 'output'
     argv = ['submit', '--module', '', program, ainput, aoutput]
     [args, unknown] = parser.parse_known_args(argv)
     self.assertEqual(args.module, '')
Пример #7
0
 def test_help(self):
     parser = app.make_parser()
     # silence!
     for k in ["submit", "script"]:
         parser._actions[2].choices[k].format_help = nop
         parser._actions[2].choices[k].format_usage = nop
         parser._actions[2].choices[k].error = nop
     parser.format_help = nop
     parser.format_usage = nop
     parser.error = nop
     try:
         args, unk = parser.parse_known_args(["-h"])
     except SystemExit as e:
         self.assertEqual(e.message, 0)
     try:
         args, unk = parser.parse_known_args(["submit", "-h"])
     except SystemExit as e:
         self.assertEqual(e.message, 0)
     try:
         args, unk = parser.parse_known_args(["submit"])
     except SystemExit as e:
         self.assertEqual(e.message, 2)
Пример #8
0
 def test_help(self):
     parser = app.make_parser()
     # silence!
     for k in ['submit', 'script']:
         parser._actions[2].choices[k].format_help = nop
         parser._actions[2].choices[k].format_usage = nop
         parser._actions[2].choices[k].error = nop
     parser.format_help = nop
     parser.format_usage = nop
     parser.error = nop
     try:
         args, unk = parser.parse_known_args(['-h'])
     except SystemExit as e:
         self.assertEqual(e.args[0], 0)
     try:
         args, unk = parser.parse_known_args(['submit', '-h'])
     except SystemExit as e:
         self.assertEqual(e.args[0], 0)
     try:
         args, unk = parser.parse_known_args(['submit'])
     except SystemExit as e:
         self.assertEqual(e.args[0], 2)
Пример #9
0
 def test_help(self):
     parser = app.make_parser()
     # silence!
     for k in ['submit', 'script']:
         parser._actions[2].choices[k].format_help = nop
         parser._actions[2].choices[k].format_usage = nop
         parser._actions[2].choices[k].error = nop
     parser.format_help = nop
     parser.format_usage = nop
     parser.error = nop
     try:
         args, unk = parser.parse_known_args(['-h'])
     except SystemExit as e:
         self.assertEqual(e.message, 0)
     try:
         args, unk = parser.parse_known_args(['submit', '-h'])
     except SystemExit as e:
         self.assertEqual(e.message, 0)
     try:
         args, unk = parser.parse_known_args(['submit'])
     except SystemExit as e:
         self.assertEqual(e.message, 2)