예제 #1
0
    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()
예제 #2
0
    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()
예제 #3
0
    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'
예제 #4
0
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()
예제 #5
0
 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()
예제 #6
0
 def test_no_setup_args(self):
     with self.assertRaises(NotImplementedError):
         script.superscript_main(args=['no_setup_args'])
예제 #7
0
 def test_supercommand(self):
     opt = script.superscript_main(args=['test_script', '--foo', 'test'])
     assert opt.get('foo') == 'test'