当前位置: 首页>>代码示例>>Python>>正文


Python simple_interpreter.Interpreter类代码示例

本文整理汇总了Python中ansibledebugger.interpreter.simple_interpreter.Interpreter的典型用法代码示例。如果您正苦于以下问题:Python Interpreter类的具体用法?Python Interpreter怎么用?Python Interpreter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Interpreter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_list

    def test_list(self, mock_stdout):
        task_name = 'test task'
        task_mock = Mock(name=task_name)
        module_name = 'test module'
        module_args = 'ma_k=ma_v'
        complex_args = {'ca_k': 'ca_v'}
        complex_args_expect = 'ca_k: ca_v'
        keyword = {'ignore_errors': False}
        keyword_expect = 'ignore_errors: \'False\''
        hostname = 'test_host'
        actual_host_expect = 'actual_host'
        conn_mock = Mock(host=actual_host_expect)
        action_plugin_wrapper_info = Mock(conn=conn_mock)
        optional_info = {'action_plugin_wrapper': action_plugin_wrapper_info}
        groups = ['a', 'b']
        groups_expect = 'a,b'
        vars = {'inventory_hostname': hostname, 'group_names': groups}
        vars.update(keyword)

        interpreter = Interpreter(TaskInfo(module_name, module_args, vars, complex_args, task=task_mock),
                                  ErrorInfo(), None, optional_info)
        interpreter.do_l(None)

        self.assertIn(task_name, mock_stdout.getvalue())
        self.assertIn(module_name, mock_stdout.getvalue())
        self.assertIn(module_args, mock_stdout.getvalue())
        self.assertIn(complex_args_expect, mock_stdout.getvalue())
        self.assertIn(keyword_expect, mock_stdout.getvalue())
        self.assertIn(hostname, mock_stdout.getvalue())
        self.assertIn(actual_host_expect, mock_stdout.getvalue())
        self.assertIn(groups_expect, mock_stdout.getvalue())
开发者ID:logic855,项目名称:ansible-playbook-debugger,代码行数:31,代码来源:interpreter_test.py

示例2: test_del_module_args_all

    def test_del_module_args_all(self, mock_stdout):
        module_args = 'key1=v1 key2=v2'
        interpreter = Interpreter(TaskInfo('', module_args, None, None),
                                  ErrorInfo(), None)

        interpreter.do_del('module_args  .  ')

        self.assertEqual(interpreter.task_info.module_args, '')
开发者ID:logic855,项目名称:ansible-playbook-debugger,代码行数:8,代码来源:interpreter_test.py

示例3: test_assign_module_args_empty_args

    def test_assign_module_args_empty_args(self, mock_stdout):
        module_args = 'key1=v1 key2=v2'
        interpreter = Interpreter(TaskInfo('', module_args, None, None),
                                  ErrorInfo(), None)

        interpreter.do_assign('module_args')

        self.assertNotEqual(module_args, interpreter.task_info.module_args)
开发者ID:logic855,项目名称:ansible-playbook-debugger,代码行数:8,代码来源:interpreter_test.py

示例4: test_print_var_in_list

    def test_print_var_in_list(self, mock_stdout):
        var = {'key': ['v1', 'v2']}
        var_expect = 'v2'
        interpreter = Interpreter(TaskInfo(None, None, var, None),
                                  ErrorInfo(), None)
        interpreter.do_p("key[1]")

        self.assertIn(var_expect, mock_stdout.getvalue())
开发者ID:logic855,项目名称:ansible-playbook-debugger,代码行数:8,代码来源:interpreter_test.py

示例5: test_print_var_in_dict

    def test_print_var_in_dict(self, mock_stdout):
        var = {'key': {'key2': 'v'}}
        var_expect = 'v'
        interpreter = Interpreter(TaskInfo(None, None, var, None),
                                  ErrorInfo(), None)
        interpreter.do_p("key['key2']")

        self.assertIn(var_expect, mock_stdout.getvalue())
开发者ID:logic855,项目名称:ansible-playbook-debugger,代码行数:8,代码来源:interpreter_test.py

示例6: test_update_module_args_ignore_nonkv

    def test_update_module_args_ignore_nonkv(self, mock_stdout):
        module_args = 'key1=v1 key2=v2'
        interpreter = Interpreter(TaskInfo('', module_args, None, None),
                                  ErrorInfo(), None)
        arg = 'nonkv_args'
        interpreter.do_update('module_args %s' % (arg))

        expected_kv = '%s' % (module_args)  # should not include arg
        self.assertEqual(expected_kv, interpreter.task_info.module_args)
开发者ID:logic855,项目名称:ansible-playbook-debugger,代码行数:9,代码来源:interpreter_test.py

示例7: test_update_module_args_skip_quote

    def test_update_module_args_skip_quote(self, mock_stdout):
        module_args = '"key1=v1" key2=v2'
        interpreter = Interpreter(TaskInfo('', module_args, None, None),
                                  ErrorInfo(), None)
        kv = 'key1=v3'
        interpreter.do_update('module_args %s' % (kv))

        expected_kv = '%s %s' % (module_args, kv)
        self.assertEqual(expected_kv, interpreter.task_info.module_args)
开发者ID:logic855,项目名称:ansible-playbook-debugger,代码行数:9,代码来源:interpreter_test.py

示例8: test_update_module_args_replace_template

    def test_update_module_args_replace_template(self, mock_stdout):
        module_args = 'key1={{ var1 }} key2=v2'
        interpreter = Interpreter(TaskInfo('', module_args, None, None),
                                  ErrorInfo(), None)
        kv = 'key1={{ var3 }}'
        interpreter.do_update('module_args %s' % (kv))

        expected_kv = '%s key2=v2' % kv
        self.assertEqual(expected_kv, interpreter.task_info.module_args)
开发者ID:logic855,项目名称:ansible-playbook-debugger,代码行数:9,代码来源:interpreter_test.py

示例9: test_set_module_args_replace_all

    def test_set_module_args_replace_all(self, mock_stdout):
        module_args = 'shell_command key1=v1 key2=v2'
        interpreter = Interpreter(TaskInfo('', module_args, None, None),
                                  ErrorInfo(), None)

        value = 'new_command key1=new_v1'
        interpreter.do_set('module_args . %s' % (value))

        self.assertEqual(value, interpreter.task_info.module_args)
开发者ID:logic855,项目名称:ansible-playbook-debugger,代码行数:9,代码来源:interpreter_test.py

示例10: test_set_complex_args_deprecated

    def test_set_complex_args_deprecated(self, mock_stdout):
        interpreter = Interpreter(TaskInfo('', '', None, None),
                                  ErrorInfo(), None)

        key = 'key1'
        value = 'v1'
        interpreter.do_set('complex_args %s %s' % (key, value))

        self.assertIn('deprecated', mock_stdout.getvalue())
开发者ID:logic855,项目名称:ansible-playbook-debugger,代码行数:9,代码来源:interpreter_test.py

示例11: test_assign_module_args_nonkv_args

    def test_assign_module_args_nonkv_args(self, mock_stdout):
        module_args = 'old_command key1=v1 key2=v2'
        interpreter = Interpreter(TaskInfo('', module_args, None, None),
                                  ErrorInfo(), None)

        new_module_args = 'new_command key3=v3 key4=v4'
        interpreter.do_assign('module_args %s' % new_module_args)

        self.assertEqual(new_module_args, interpreter.task_info.module_args)
开发者ID:logic855,项目名称:ansible-playbook-debugger,代码行数:9,代码来源:interpreter_test.py

示例12: test_assign_complex_args_wrong_yaml

    def test_assign_complex_args_wrong_yaml(self, mock_stdout):
        interpreter = Interpreter(TaskInfo('', '', None, None),
                                  ErrorInfo(), None)

        new_args = ['key2: v2', '- key3: v3', '']
        with patch('__builtin__.raw_input', side_effect=new_args[1:]):
            interpreter.do_assign('complex_args %s' % (new_args[0]))

        expect = 'Failed to parse YAML'
        self.assertIn(expect, mock_stdout.getvalue())
开发者ID:logic855,项目名称:ansible-playbook-debugger,代码行数:10,代码来源:interpreter_test.py

示例13: test_del_complex_args_del_all

    def test_del_complex_args_del_all(self, mock_stdout):
        complex_args = {'key1': 'v1', 'key2': 'v2'}
        interpreter = Interpreter(TaskInfo('', '', None, complex_args),
                                  ErrorInfo(), None)

        key = '.'
        interpreter.do_del('complex_args %s' % (key))

        expect = {}
        self.assertEqual(interpreter.task_info.complex_args, expect)
开发者ID:logic855,项目名称:ansible-playbook-debugger,代码行数:10,代码来源:interpreter_test.py

示例14: test_update_complex_args_empty_kv

    def test_update_complex_args_empty_kv(self, mock_stdout):
        complex_args = {'key1': 'v1'}
        interpreter = Interpreter(TaskInfo('', '', None, complex_args),
                                  ErrorInfo(), None)

        with patch('__builtin__.raw_input', side_effect=['']):
            interpreter.do_update('complex_args')

        expect = {'key1': 'v1'}  # change nothing
        self.assertEqual(interpreter.task_info.complex_args, expect)
开发者ID:logic855,项目名称:ansible-playbook-debugger,代码行数:10,代码来源:interpreter_test.py

示例15: test_del_module_args_template

    def test_del_module_args_template(self, mock_stdout):
        module_args = 'key1={{ var1 }} key2=v2'
        interpreter = Interpreter(TaskInfo('', module_args, None, None),
                                  ErrorInfo(), None)

        key = 'key1'
        interpreter.do_del('module_args %s' % (key))

        expect = 'key2=v2'
        self.assertEqual(interpreter.task_info.module_args, expect)
开发者ID:logic855,项目名称:ansible-playbook-debugger,代码行数:10,代码来源:interpreter_test.py


注:本文中的ansibledebugger.interpreter.simple_interpreter.Interpreter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。