Exemplo n.º 1
0
    def test_quit_tab(self):
        """Test console response to Q+tab (should be 'quit').

        NOTICE: This test is designed to be executed from the base of the
        source tree. If you want to run it from elsewhere, you will need
        to change the 'utildir' variable below.

        """
        options = {
            'verbosity': False,
            'quiet': False,
            'width': 80,
            'utildir': "./scripts",
            'variables': [],
            'prompt': '>',
            'welcome': "",
            'goodbye': "",
            'commands': [],
            'custom': True,
            'hide_util': False,
            'add_util': []
        }
        util_con = UtilitiesConsole(options)
        stdout_backup = sys.stdout
        try:
            sys.stdout = open(os.devnull, 'w')
            test_cases = ["q", "Q"]
            for key in test_cases:
                util_con.cmd_line.command = ""
                util_con.cmd_line.add(key)
                util_con.do_command_tab("q")
                self.assertEqual(util_con.cmd_line.command,
                                 "{0}uit ".format(key))
        finally:
            sys.stdout = stdout_backup
Exemplo n.º 2
0
 def setUp(self):
     options = {
         'verbosity': False,
         'quiet': False,
         'width': 80,
         'utildir': _UTIL_DIR,
         'variables': [],
         'prompt': '>',
         'welcome': "",
         'goodbye': "",
         'commands': [],
         'custom': True,
         'hide_util': False,
         'add_util': []
     }
     self.util_con = UtilitiesConsole(options)
Exemplo n.º 3
0
    extra_utils_dict = {}
    for utility in opt.add_util:
        extra_utils_dict[utility] = ()

    options = {
        'verbosity': verbosity,
        'quiet': quiet,
        'width': opt.width,
        'utildir': opt.utildir,
        'variables': build_variable_dictionary_list(args),
        'prompt': 'mysqluc> ',
        'welcome': WELCOME_MESSAGE.format(VERSION_STRING, COPYRIGHT_FULL),
        'goodbye': GOODBYE_MESSAGE,
        'commands': opt.commands,
        'custom': True,  # We are using custom commands
        'hide_util': opt.hide_util,
        'add_util': extra_utils_dict
    }

    try:
        print("Launching console ...")
        util_con = UtilitiesConsole(options)
        util_con.run_console()
    except KeyboardInterrupt:
        print(options['goodbye'])
    except UtilError:
        _, e, _ = sys.exc_info()
        print("ERROR: %s" % e.errmsg)

    sys.exit()