Example #1
0
    def test_optcomplete(self):
        """Test optcomplete support"""

        reg_reply = re.compile(r'^COMPREPLY=\((.*)\)$')

        script = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'runtests', 'simple_option.py')

        partial = '-'
        cmd_list = [script, partial]

        ec, out = run_simple('%s; test $? == 1' % gen_cmdline(cmd_list, partial))
        # tabcompletion ends with exit 1!; test returns this to 0
        # avoids run.log.error message
        self.assertEqual(ec, 0)

        compl_opts = reg_reply.search(out).group(1).split()
        basic_opts = ['--debug', '--enable-debug', '--disable-debug', '-d',
                      '--help', '-h', '-H', '--shorthelp',
                      '--configfiles', '--info',
                      ]
        for opt in basic_opts:
            self.assertTrue(opt in compl_opts)

        # test --deb autocompletion
        partial = '--deb'
        cmd_list = [script, partial]

        ec, out = run_simple('%s; test $? == 1' % gen_cmdline(cmd_list, partial))
        # tabcompletion ends with exit 1!; test returns this to 0
        # avoids run.log.error message
        self.assertEqual(ec, 0)

        compl_opts = reg_reply.search(out).group(1).split()
        self.assertEqual(compl_opts, ['--debug'])
Example #2
0
    def test_optcomplete(self):
        """Test optcomplete support"""

        reg_reply = re.compile(r'^COMPREPLY=\((.*)\)$')

        script_name = 'simple_option.py'
        script_simple = os.path.join(os.path.dirname(__file__), 'runtests', script_name)

        partial = '-'
        cmd_list = [script_simple, partial]

        ec, out = run_simple('%s; test $? == 1' % gen_cmdline(cmd_list, partial))
        # tabcompletion ends with exit 1!; test returns this to 0
        # avoids run.log.error message
        self.assertEqual(ec, 0)

        compl_opts = reg_reply.search(out).group(1).split()
        basic_opts = ['--debug', '--enable-debug', '--disable-debug', '-d',
                      '--help', '-h', '-H', '--shorthelp',
                      '--configfiles', '--info',
                      ]
        for opt in basic_opts:
            self.assertTrue(opt in compl_opts)

        # test --deb autocompletion
        partial = '--deb'
        cmd_list = [script_simple, partial]

        ec, out = run_simple('%s; test $? == 1' % gen_cmdline(cmd_list, partial))
        # tabcompletion ends with exit 1!; test returns this to 0
        # avoids run.log.error message
        self.assertEqual(ec, 0)

        compl_opts = reg_reply.search(out).group(1).split()
        self.assertEqual(compl_opts, ['--debug'])
    def test_optcomplete(self):
        """Test optcomplete support"""

        reg_reply = re.compile(r'^COMPREPLY=\((.*)\)$')

        script = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                              'runtests', 'simple_option.py')

        partial = '-'
        cmd_list = [script, partial]

        os.environ['SHELL'] = "bash"
        pythonpath = 'PYTHONPATH="%s"' % os.pathsep.join(
            [p for p in sys.path if p.startswith(self.setup.REPO_BASE_DIR)])
        ec, out = run_simple(
            '%s %s; test $? == 1' %
            (pythonpath, gen_cmdline(cmd_list, partial, shebang=False)))
        # tabcompletion ends with exit 1!; test returns this to 0
        # avoids run.log.error message
        self.assertEqual(ec, 0, msg="simple_option.py test script ran success")

        print(out)
        reply_match = reg_reply.search(out)
        self.assertTrue(reply_match,
                        msg="COMPREPLY %s in output %s" %
                        (reg_reply.pattern, out))

        compl_opts = reply_match.group(1).split()
        basic_opts = [
            '--debug',
            '--enable-debug',
            '--disable-debug',
            '-d',
            '--help',
            '-h',
            '-H',
            '--shorthelp',
            '--configfiles',
            '--info',
        ]
        for opt in basic_opts:
            self.assertTrue(opt in compl_opts)

        # test --deb autocompletion
        partial = '--deb'
        cmd_list = [script, partial]

        ec, out = run_simple(
            '%s %s; test $? == 1' %
            (pythonpath, gen_cmdline(cmd_list, partial, shebang=False)))
        # tabcompletion ends with exit 1!; test returns this to 0
        # avoids run.log.error message
        self.assertEqual(ec, 0)

        compl_opts = reg_reply.search(out).group(1).split()
        self.assertEqual(compl_opts, ['--debug'])
Example #4
0
 def test_gen_cmdline(self):
     """Test generation of commndline"""
     partial = 'z'
     cmd_list = ['x', 'y', partial]
     cmdline = gen_cmdline(cmd_list, partial)
     for word in [OPTCOMPLETE_ENVIRONMENT, 'COMP_LINE', 'COMP_WORDS', 'COMP_CWORD', 'COMP_POINT']:
         self.assertTrue("%s=" % word in cmdline)
Example #5
0
 def test_gen_cmdline(self):
     """Test generation of commndline"""
     partial = 'z'
     cmd_list = ['x', 'y', partial]
     cmdline = gen_cmdline(cmd_list, partial)
     for word in [
             OPTCOMPLETE_ENVIRONMENT, 'COMP_LINE', 'COMP_WORDS',
             'COMP_CWORD', 'COMP_POINT'
     ]:
         self.assertTrue("%s=" % word in cmdline)
Example #6
0
    def test_optcomplete(self):
        """Test optcomplete support"""

        reg_reply = re.compile(r'^COMPREPLY=\((.*)\)$')

        script = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'runtests', 'simple_option.py')

        partial = '-'
        cmd_list = [script, partial]

        os.environ['SHELL'] = "bash"
        pythonpath = 'PYTHONPATH="%s"' % os.pathsep.join([p for p in sys.path if p.startswith(self.setup.REPO_BASE_DIR)])
        ec, out = run_simple('%s %s; test $? == 1' % (pythonpath, gen_cmdline(cmd_list, partial, shebang=False)))
        # tabcompletion ends with exit 1!; test returns this to 0
        # avoids run.log.error message
        self.assertEqual(ec, 0, msg="simple_option.py test script ran success")

        print out
        reply_match = reg_reply.search(out)
        self.assertTrue(reply_match, msg="COMPREPLY %s in output %s" % (reg_reply.pattern, out))

        compl_opts = reply_match.group(1).split()
        basic_opts = ['--debug', '--enable-debug', '--disable-debug', '-d',
                      '--help', '-h', '-H', '--shorthelp',
                      '--configfiles', '--info',
                      ]
        for opt in basic_opts:
            self.assertTrue(opt in compl_opts)

        # test --deb autocompletion
        partial = '--deb'
        cmd_list = [script, partial]

        ec, out = run_simple('%s %s; test $? == 1' % (pythonpath, gen_cmdline(cmd_list, partial, shebang=False)))
        # tabcompletion ends with exit 1!; test returns this to 0
        # avoids run.log.error message
        self.assertEqual(ec, 0)

        compl_opts = reg_reply.search(out).group(1).split()
        self.assertEqual(compl_opts, ['--debug'])