def test_help(self): with testing_utils.capture_output() as output: script.superscript_main(args=['help']) assert 'test_script' in output.getvalue() assert 'hidden_script' not in output.getvalue() with testing_utils.capture_output() as output: script.superscript_main(args=['helpall']) assert 'test_script' in output.getvalue() assert 'hidden_script' in output.getvalue()
def test_help(self): with testing_utils.capture_output() as output: script.superscript_main(args=['help']) assert 'test_script' in output.getvalue() assert 'hidden_script' not in output.getvalue() # showing help for the super command, not the subcommand assert '--foo' not in output.getvalue() with testing_utils.capture_output() as output: script.superscript_main(args=['helpall']) assert 'test_script' in output.getvalue() assert 'hidden_script' in output.getvalue()
def test_shortopt(self): """ Tests whether short opts with multiple letters parse correctly. Known tricky in python 3.8. """ opt = script.superscript_main(args=['short_opt', '-m', 'repeat_query']) assert opt.get('model') == 'repeat_query' opt = script.superscript_main( args=['short_opt', '-m', 'transformer/generator', '-opt', 'adam']) assert opt.get('optimizer') == 'adam'
def main(): # indirect call so that console_entry (see setup.py) doesn't use the return # value of the final command as the return code. This lets us call # superscript_main as a function in other places (test_script.py). superscript_main()
def test_subcommand_help(self): with testing_utils.capture_output() as output: with self.assertRaises(SystemExit): script.superscript_main(args=['test_script', 'foo']) assert 'parlai test_script' in output.getvalue() assert '--foo' in output.getvalue()
def test_no_setup_args(self): with self.assertRaises(NotImplementedError): script.superscript_main(args=['no_setup_args'])
def test_supercommand(self): opt = script.superscript_main(args=['test_script', '--foo', 'test']) assert opt.get('foo') == 'test'