def _fix_opt(self, opt_key, opt_value, source): """Check sh_bin""" opt_value = super(MRJobBinRunner, self)._fix_opt( opt_key, opt_value, source) # check that sh_bin doesn't have too many args if opt_key == 'sh_bin': # opt_value is usually a string, combiner makes it a list of args sh_bin = combine_cmds(opt_value) # empty sh_bin just means to use the default, see #1926 # make these hard requirements in v0.7.0? if len(sh_bin) > 1 and not os.path.isabs(sh_bin[0]): log.warning('sh_bin (from %s) should use an absolute path' ' if you want it to take arguments' % source) elif len(sh_bin) > 2: log.warning('sh_bin (from %s) should not take more than one' ' argument' % source) return opt_value
def test_convert_to_list(self): assert_equal(combine_cmds('sort', ('grep', '-E')), ['grep', '-E'])
def test_parse_empty_string(self): assert_equal(combine_cmds(''), [])
def test_parse_string(self): assert_equal(combine_cmds('sort', 'grep', 'cat'), ['cat']) assert_equal(combine_cmds(['python'], 'python -S'), ['python', '-S'])
def test_all_None(self): assert_equal(combine_cmds(None, None, None), None)
def test_picks_last_value(self): assert_equal(combine_cmds(['sort'], ['grep'], ['cat']), ['cat'])
def test_empty(self): assert_equal(combine_cmds(), None)
def test_all_None(self): self.assertEqual(combine_cmds(None, None, None), None)
def test_empty(self): self.assertEqual(combine_cmds(), None)
def test_unicode(self): self.assertEqual(combine_cmds(u"wunderbar!"), ["wunderbar!"])
def test_convert_to_list(self): self.assertEqual(combine_cmds("sort", ("grep", "-E")), ["grep", "-E"])
def test_parse_empty_string(self): self.assertEqual(combine_cmds(""), [])
def test_parse_string(self): self.assertEqual(combine_cmds("sort", "grep", "cat"), ["cat"]) self.assertEqual(combine_cmds(["python"], "python -S"), ["python", "-S"])
def test_picks_last_value(self): self.assertEqual(combine_cmds(["sort"], ["grep"], ["cat"]), ["cat"])
def test_unicode(self): self.assertEqual(combine_cmds(u'wunderbar!'), ['wunderbar!'])