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


Python lang.Command类代码示例

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


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

示例1: test_scl_passes_scls_list_to_command_invocation

 def test_scl_passes_scls_list_to_command_invocation(self):
     # please don't use $__scls__ in actual assistants :)
     # scl runner has to use the unformatted input
     inp = [{'log_i': '$__scls__'}]
     c = Command('scl enable foo bar', inp)
     c.run()
     assert ('INFO', "[['enable', 'foo', 'bar']]") in self.tlh.msgs
开发者ID:Rorosha,项目名称:devassistant,代码行数:7,代码来源:test_command_runners.py

示例2: test_render_dir

 def test_render_dir(self, tmpdir):
     dr = 'dirwithmoretemplates'
     self.make_sure_file_does_not_exists(tmpdir, dr)
     inp = {'template': {'source': dr},
            'data': {'foo': 'foo', 'bar': 'bar'},
            'destination': tmpdir.strpath}
     c = Command('jinja_render_dir',
                 inp,
                 kwargs={'__files_dir__': [self.filesdir]})
     c.run()
     assert self.is_file_exists(tmpdir, 'asd') and self.get_file_contents(tmpdir, 'asd') == 'foo'
     assert self.is_file_exists(tmpdir, 'foo/sdf') and self.get_file_contents(tmpdir, 'foo/sdf') == 'bar'
开发者ID:jumping,项目名称:devassistant,代码行数:12,代码来源:test_command_runners.py

示例3: test_render_tpl_file_default_case_2

 def test_render_tpl_file_default_case_2(self, tmpdir):
     fn = 'jinja_template.py'
     # Case 2: output filename will be the same!
     fntpl = fn
     self.make_sure_file_does_not_exists(tmpdir, fn)
     inp = {'template': {'source': fntpl},
            'data': {'what': 'foo'},
            'destination': tmpdir.strpath}
     c = Command('jinja_render',
                 inp,
                 kwargs={'__files_dir__': [self.filesdir]})
     c.run()
     assert self.is_file_exists(tmpdir, fn) and self.get_file_contents(tmpdir, fn) == 'print("foo")'
开发者ID:jumping,项目名称:devassistant,代码行数:13,代码来源:test_command_runners.py

示例4: test_render_tpl_file_set_output_case

 def test_render_tpl_file_set_output_case(self, tmpdir):
     # Case 3: set desired output name explicitly
     fn ='rendered_jinja_template.py'
     fntpl = 'jinja_template.py.tpl'
     self.make_sure_file_does_not_exists(tmpdir, fn)
     inp = {'template': {'source': fntpl},
            'data': {'what': 'foo'},
            'output': fn,
            'destination': tmpdir.strpath}
     c = Command('jinja_render',
                 inp,
                 kwargs={'__files_dir__': [self.filesdir]})
     c.run()
     assert self.is_file_exists(tmpdir, fn) and self.get_file_contents(tmpdir, fn) == 'print("foo")'
开发者ID:jumping,项目名称:devassistant,代码行数:14,代码来源:test_command_runners.py

示例5: test_render_with_tpl_in_file_subdir

 def test_render_with_tpl_in_file_subdir(self, tmpdir):
     # if we get a template with source e.g. dirwithmoretemplates/foo.tpl,
     #  we should still get just foo.tpl without the subdir as a result
     fn = 'asd'
     fntpl = 'dirwithmoretemplates/asd.tpl'
     self.make_sure_file_does_not_exists(tmpdir, fn)
     inp = {'template': {'source': fntpl},
            'data': {'foo': 'foo'},
            'output': fn,
            'destination': tmpdir.strpath}
     c = Command('jinja_render',
                 inp,
                 kwargs={'__files_dir__': [self.filesdir]})
     c.run()
     assert self.is_file_exists(tmpdir, fn) and self.get_file_contents(tmpdir, fn) == 'foo'
开发者ID:GavinKenna,项目名称:devassistant,代码行数:15,代码来源:test_command_runners.py

示例6: test_run_with_specified_args

    def test_run_with_specified_args(self):
        kwargs = {'spam': 'something',
                  'nospam': 'hahaha',
                  '__magic_val__': 'it\'s magical',
                  '__assistant__': self.ass['leaf']}

        com = Command('use', {'sect': 'self.run',
                              'args': {'spam': 'something else', 'spam2': 'blah'}}, kwargs)

        class Matcher(object):
            def __eq__(self, other):
                assert len(other) == 4
                assert other['spam'] == 'something else'
                assert other['spam2'] == 'blah'
                assert other['__magic_val__'] == 'it\'s magical'
                assert '__assistant__' in other
                return True

        flexmock(lang).should_receive('run_section').with_args(list, Matcher())
        com.run()
开发者ID:GavinKenna,项目名称:devassistant,代码行数:20,代码来源:test_command_runners.py

示例7: test_scl_with_nested_calls

 def test_scl_with_nested_calls(self):
     # https://github.com/bkabrda/devassistant/issues/234
     # tests proper nesting of SCL commands and also elimination of identical calls
     inp = [{'scl enable hamham foo': [{'scl enable spamspam': [{'cl': 'ls'}]}]}]
     c = Command('scl enable spamspam', inp)
     with pytest.raises(RunException):
         c.run()
     # make sure to remove scl command processors from ClHelper
     ClHelper.command_processors = {}
     res_lines = [['scl enable spamspam - << DA_SCL_enable_spamspam_EOF',
                   'scl enable hamham foo - << DA_SCL_enable_hamham_foo_EOF',
                   'ls',
                   'DA_SCL_enable_hamham_foo_EOF',
                   'DA_SCL_enable_spamspam_EOF']]
     # shuffle first two and last two lines to get possible permutations of scl
     #  call order (command processors are in dict, which has arbitrary order)
     res_lines.append(copy.deepcopy(res_lines[0]))
     res_lines[1][0], res_lines[1][1] = res_lines[1][1], res_lines[1][0]
     res_lines[1][3], res_lines[1][4] = res_lines[1][4], res_lines[1][3]
     assert ('DEBUG', '\n'.join(res_lines[0])) in self.tlh.msgs or \
            ('DEBUG', '\n'.join(res_lines[1])) in self.tlh.msgs
开发者ID:GavinKenna,项目名称:devassistant,代码行数:21,代码来源:test_command_runners.py

示例8: test_correct_cases

    def test_correct_cases(self, tmpdir, path, comm_args, normalized, varnames):
        if not varnames:
            varnames = ['contdir', 'topdir', 'topdir_normalized']
        kwargs = {'name': path}
        comm_args['from'] = '$name'
        c = Command('setup_project_dir', comm_args, kwargs=kwargs)

        with tmpdir.as_cwd():
            ret = c.run()
            create_topdir = comm_args.get('create_topdir', True)
            p = path
            if create_topdir is True:
                assert ret == (True, p)
            elif create_topdir == 'normalized':
                p = os.path.join(os.path.dirname(path), normalized)
                assert ret == (True, p)
            else:
                p = os.path.dirname(path)
                assert ret == (True, p)
            assert os.path.isdir(p)
            # if os.path.dirname(path) == '', then '.' should be saved instead
            assert kwargs[varnames[0]] == (os.path.dirname(path) or '.')
            assert kwargs[varnames[1]] == os.path.basename(path)
            assert kwargs[varnames[2]] == normalized
开发者ID:GavinKenna,项目名称:devassistant,代码行数:24,代码来源:test_command_runners.py

示例9: test_doesn_fail_when_dir_exists_but_overrided

 def test_doesn_fail_when_dir_exists_but_overrided(self, tmpdir):
     c = Command('setup_project_dir', {'from': 'foo', 'on_existing': 'pass'})
     with tmpdir.as_cwd():
         os.makedirs('foo')
         assert c.run() == (True, 'foo')
开发者ID:GavinKenna,项目名称:devassistant,代码行数:5,代码来源:test_command_runners.py

示例10: test_fails_when_dir_exists

 def test_fails_when_dir_exists(self, tmpdir):
     c = Command('setup_project_dir', {'from': 'foo'})
     with tmpdir.as_cwd():
         open('foo', 'w').close()
         with pytest.raises(CommandException):
             c.run()
开发者ID:GavinKenna,项目名称:devassistant,代码行数:6,代码来源:test_command_runners.py

示例11: test_failure_cases

 def test_failure_cases(self, inp):
     c = Command('setup_project_dir', inp)
     with pytest.raises(CommandException):
         c.run()
开发者ID:GavinKenna,项目名称:devassistant,代码行数:4,代码来源:test_command_runners.py


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