Esempio n. 1
0
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'}"""
Esempio n. 2
0
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'"""
Esempio n. 3
0
#!/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())
Esempio n. 4
0
#!/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())
Esempio n. 5
0
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'}"""
Esempio n. 6
0
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'}"""
Esempio n. 7
0
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 = ''"