Пример #1
0
def test_switches_contains():
    switch = Switches(create_argv(test_command_1))
    assert len(switch) == 4
    assert switch.contains(["s"]) == True
    assert switch.contains(["long"]) == True
    assert switch.contains(["n"]) == True
    assert switch.contains(["name"]) == True
    assert switch.contains(["s", "long"]) == True
    assert switch.contains(["long", "name"]) == True
    assert switch.contains(["bogus"]) == False
    assert switch.contains(["s", "long", "bogus"]) == False
    assert switch.contains([""]) == False
def test_switches_instantiation():
    switch = Switches(create_argv(test_command_1))
    assert isinstance(switch, set)
    assert len(switch) == 4
    assert ("s" in switch) == True
    assert ("long" in switch) == True
    assert ("n" in switch) == True
    assert ("name" in switch) == True
def test_switch_instantiation_with_doubledash():
    """This test should ignore any switches that meet switch syntax definition after the `--` idiom"""
    switch = Switches(create_argv(test_command_11))
    assert isinstance(switch, set)
    assert len(switch) == 2
    assert ("t" in switch) == True
    assert ("name" in switch) == True
    assert ("s" in switch) == False
    assert ("--" in switch) == False
    assert ("" in switch) == False
def test_switches_contains():
    switch = Switches(create_argv(test_command_1))
    assert len(switch) == 4
    assert switch.contains(['s']) == True
    assert switch.contains(['long']) == True
    assert switch.contains(['n']) == True
    assert switch.contains(['name']) == True
    assert switch.contains(['s', 'long']) == True
    assert switch.contains(['long', 'name']) == True
    assert switch.contains(['bogus']) == False
    assert switch.contains(['s', 'long', 'bogus']) == False
    assert switch.contains(['']) == False
def test_switch_instantiation_with_mops():
    switch = Switches(create_argv(test_command_9))
    assert isinstance(switch, set)
    assert len(switch) == 2
    assert ("t" in switch) == True
    assert ("mops" in switch) == True
def test_switch_instantiation_noswitches():
    switch = Switches(create_argv(test_command_6))
    assert isinstance(switch, set)
    assert len(switch) == 0
def test_mops_str_method_empty():
    switches_set = Switches(create_argv(test_command_6))
    assert len(switches_set) == 0
    assert switches_set.__str__() == """{}"""
def test_mops_str_method():
    switches_set = Switches(create_argv(test_command_4))
    assert len(switches_set) == 2
    assert switches_set.__str__() == """{'v', 'V'}""" or switches_set.__repr__(
    ) == """{'V', 'v'}"""
Пример #9
0
def test_mops_str_method_empty():
    switches_set = Switches(create_argv(test_command_6))
    assert len(switches_set) == 0
    assert switches_set.__str__() == """{}"""
Пример #10
0
def test_mops_str_method():
    switches_set = Switches(create_argv(test_command_4))
    assert len(switches_set) == 2
    assert switches_set.__str__() == """{'v', 'V'}""" or switches_set.__repr__() == """{'V', 'v'}"""