Exemple #1
0
    def test_get_user_options_dynamic(self, parseArguments):
        # Check the user options are generated after
        # the command line options created in green.cmdline.parseArguments
        store_opt = StoreOpt()
        argparser = argparse.ArgumentParser()
        store_opt(argparser.add_argument("-s", "--something", help="Something"))
        store_opt(argparser.add_argument("--else", help="Else"))
        store_opt(
            argparser.add_argument("-a", "--again", action="store_true", help="Again")
        )

        args = argparser.parse_args([])
        args.parser = argparser
        args.store_opt = store_opt
        parseArguments.return_value = args

        options = command.get_user_options()

        self.assertEqual(
            options,
            [
                ("something=", "s", "Something"),
                ("else=", None, "Else"),
                ("again", "a", "Again"),
            ],
        )
Exemple #2
0
    def test_get_user_options_setup_py(self):
        """
        When get_user_options() is called by 'python setup.py --help-commands',
        it returns [] early and doesn't crash.
        """
        sys.argv.append("--help-commands")
        self.addCleanup(lambda: sys.argv.pop())

        self.assertEqual(command.get_user_options(), [])
Exemple #3
0
    def test_get_user_options_setup_py(self):
        """
        When get_user_options() is called by 'python setup.py --help-commands',
        it returns [] early and doesn't crash.
        """
        sys.argv.append('--help-commands')
        self.addCleanup(lambda: sys.argv.pop())

        self.assertEqual(command.get_user_options(), [])
Exemple #4
0
    def test_get_user_options(self):
        # Check the user options contain some of the
        # actual command line options
        options = command.get_user_options()

        self.assertIn(
            ("options", None,
             "Output all options.  Used by bash- and zsh-completion."),
            options)

        self.assertIn(('file-pattern=', 'p',
                       'Pattern to match test files. Default is test*.py'),
                      options)
Exemple #5
0
    def test_get_user_options(self):
        # Check the user options contain some of the
        # actual command line options
        options = command.get_user_options()

        self.assertIn(
            ("options", None,
             "Output all options.  Used by bash- and zsh-completion."),
            options
        )

        self.assertIn(
            ('file-pattern=', 'p',
             'Pattern to match test files. Default is test*.py'),
            options
        )
Exemple #6
0
    def test_get_user_options_dynamic(self, parseArguments):
        # Check the user options are generated after
        # the command line options created in green.cmdline.parseArguments
        store_opt = StoreOpt()
        argparser = argparse.ArgumentParser()
        store_opt(argparser.add_argument("-s", "--something", help="Something"))
        store_opt(argparser.add_argument("--else", help="Else"))
        store_opt(argparser.add_argument("-a", "--again", action="store_true", help="Again"))

        args = argparser.parse_args([])
        args.parser = argparser
        args.store_opt = store_opt
        parseArguments.return_value = args

        options = command.get_user_options()

        self.assertEqual(options, [
            ('something=', 's', 'Something'),
            ('else=', None, 'Else'),
            ('again', 'a', 'Again'),
        ])