Esempio n. 1
0
def test_list_string_option():
    o = Option("t", short="-t", nargs="*")
    assert str(o) == ""
    o.value = "test"
    assert str(o) == "test"
    assert o.to_cmd() == "-t test"
    o.value = ["t1", "t2"]
    assert str(o) == "t1 t2"
    assert o.to_cmd() == "-t t1 t2"
Esempio n. 2
0
def test_list_string_option():
    o = Option("t", short="-t", nargs="*")
    assert str(o) == ""
    o.value = "test"
    assert str(o) == "test"
    assert o.to_cmd() == "-t test"
    o.value = ["t1", "t2"]
    assert str(o) == "t1 t2"
    assert o.to_cmd() == "-t t1 t2"
Esempio n. 3
0
def test_options_equality():
    string_opt = Option("test")
    assert string_opt == None
    string_opt.value = "TEST1"
    assert string_opt == "TEST1"
    string_opt.append("TEST2")
    assert string_opt != "TEST1"
    assert string_opt == ["TEST1", "TEST2"]
    assert string_opt
    string_opt.value = False
    assert not string_opt
Esempio n. 4
0
def test_options_equality():
    string_opt = Option('test')
    assert string_opt == None
    string_opt.value = "TEST1"
    assert string_opt == "TEST1"
    string_opt.append("TEST2")
    assert string_opt != "TEST1"
    assert string_opt == ["TEST1", "TEST2"]
    assert string_opt
    string_opt.value = False
    assert not string_opt
Esempio n. 5
0
def test_list_option_rendering():
    o = Option("test", nargs="*")
    o.value = ["A", "B"]
    from jip.templates import render_template

    assert render_template("${o}", o=o) == "A B"
    assert render_template("${o|join(',')}", o=o) == "A,B"
Esempio n. 6
0
def test_single_string_option():
    o = Option("t", short="-t", nargs=1)
    assert str(o) == ""
    assert o.to_cmd() == ""
    o.value = "test"
    assert str(o) == "test"
    assert o.to_cmd() == "-t test"
Esempio n. 7
0
def test_single_string_option():
    o = Option("t", short="-t", nargs=1)
    assert str(o) == ""
    assert o.to_cmd() == ""
    o.value = "test"
    assert str(o) == "test"
    assert o.to_cmd() == "-t test"
Esempio n. 8
0
def test_boolean_option():
    o = Option("t", short="-t", default=False)
    assert o.name == "t"
    assert o.short == "-t"
    assert not o.default
    assert o.value == [False]
    assert str(o) == ""
    assert o.to_cmd() == ""
    o.value = True
    assert str(o) == ""
    assert o.to_cmd() == "-t"
Esempio n. 9
0
def test_boolean_option():
    o = Option("t", short="-t", default=False)
    assert o.name == "t"
    assert o.short == "-t"
    assert not o.default
    assert o.value == [False]
    assert str(o) == ""
    assert o.to_cmd() == ""
    o.value = True
    assert str(o) == ""
    assert o.to_cmd() == "-t"
Esempio n. 10
0
def test_list_option_rendering():
    o = Option('test', nargs="*")
    o.value = ["A", "B"]
    from jip.templates import render_template
    assert render_template("${o}", o=o) == 'A B'
    assert render_template("${o|join(',')}", o=o) == 'A,B'