本文整理汇总了Python中commandlines.Command.obj_string方法的典型用法代码示例。如果您正苦于以下问题:Python Command.obj_string方法的具体用法?Python Command.obj_string怎么用?Python Command.obj_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类commandlines.Command
的用法示例。
在下文中一共展示了Command.obj_string方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_command_obj_defaults_set
# 需要导入模块: from commandlines import Command [as 别名]
# 或者: from commandlines.Command import obj_string [as 别名]
def test_command_obj_defaults_set():
set_sysargv(test_command_7)
c = Command()
c.set_defaults({'test': 'arg'})
returned_string = c.obj_string()
returned_string_list = returned_string.split("\n")
assert returned_string_list[2] == """obj.defaults = {'test': 'arg'}"""
示例2: test_command_obj_string
# 需要导入模块: from commandlines import Command [as 别名]
# 或者: from commandlines.Command import obj_string [as 别名]
def test_command_obj_string():
set_sysargv(test_command_1)
c = Command()
returned_string = c.obj_string()
returned_string_list = returned_string.split("\n")
assert returned_string_list[0] == "obj.argc = 9"
assert returned_string_list[1] == """obj.arguments = ['subcmd', '-s', '--long', '-n', 'shortdef', '--name', 'longdef', '--nameeq=longdefeq', 'lastpos']"""
assert returned_string_list[2] == """obj.defaults = {}"""
assert returned_string_list[5] == """obj.mdefs = {}"""
assert returned_string_list[6] == """obj.mops = {}"""
assert returned_string_list[7] == """obj.arg0 = 'subcmd'"""
assert returned_string_list[8] == """obj.arg1 = '-s'"""
assert returned_string_list[9] == """obj.arg2 = '--long'"""
assert returned_string_list[10] == """obj.arg3 = '-n'"""
assert returned_string_list[11] == """obj.arg4 = 'shortdef'"""
assert returned_string_list[12] == """obj.arglp = 'lastpos'"""
assert returned_string_list[13] == """obj.subcmd = 'subcmd'"""
assert returned_string_list[14] == """obj.subsubcmd = '-s'"""
示例3: set_sysargv
# 需要导入模块: from commandlines import Command [as 别名]
# 或者: from commandlines.Command import obj_string [as 别名]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from commandlines import Command
import sys
import shlex
test_command_1 = "spam eggs --toast -b --drink=milk filepath"
test_command_13 = "executable -o path1 -o path2 -t --flag"
test_command_18 = "executable -o path1 -o path2 --file tests/path1 --file tests/path2"
test_command_19 = "executable -mops -t --test=bogus --test=another --help me"
def set_sysargv(argstring):
sys.argv = shlex.split(argstring)
set_sysargv(test_command_13)
c = Command()
print(c.obj_string())
示例4: test_command_obj_string_4
# 需要导入模块: from commandlines import Command [as 别名]
# 或者: from commandlines.Command import obj_string [as 别名]
def test_command_obj_string_4():
set_sysargv(test_command_7)
c = Command()
returned_string = c.obj_string()
returned_string_list = returned_string.split("\n")
assert returned_string_list[4] == """obj.defs = {'m': 'initial commit'}"""
示例5: test_command_obj_string_3
# 需要导入模块: from commandlines import Command [as 别名]
# 或者: from commandlines.Command import obj_string [as 别名]
def test_command_obj_string_3():
set_sysargv(test_command_11)
c = Command()
returned_string = c.obj_string()
returned_string_list = returned_string.split("\n")
assert returned_string_list[4] == """obj.defs = {'long': 'test'}"""
示例6: test_command_obj_string_2
# 需要导入模块: from commandlines import Command [as 别名]
# 或者: from commandlines.Command import obj_string [as 别名]
def test_command_obj_string_2():
set_sysargv(test_command_9)
c = Command()
returned_string = c.obj_string()
returned_string_list = returned_string.split("\n")
assert returned_string_list[11] == "obj.arg4 = ''"