Exemplo n.º 1
0
def test_match():
    tokens = [["word", "test"], ["int", 1]]
    assert args.match(tokens, "word") == "test", "Wrong word on match."
    assert args.match(tokens) == 1, "Wrong int on match."

    assert len(
        tokens) == 0, "There should be nothing in the array after matching."
def test_peek():
    tokens = [["word", "test"],["int", 1]]
    assert args.peek(tokens, "word"), "There should be a word."
    assert len(tokens) == 2, "Args should not go down after peek."
    args.match(tokens, "word")

    assert args.peek(tokens, "int"), "There should be an int."
    assert not args.peek(tokens, "option"), "There should not be an option."
    args.match(tokens, "int")
Exemplo n.º 3
0
def test_peek():
    tokens = [["word", "test"], ["int", 1]]
    assert args.peek(tokens, "word"), "There should be a word."
    assert len(tokens) == 2, "Args should not go down after peek."
    args.match(tokens, "word")

    assert args.peek(tokens, "int"), "There should be an int."
    assert not args.peek(tokens, "option"), "There should not be an option."
    args.match(tokens, "int")
def test_tokenize():
    tokens = args.tokenize(['test', '--num', '1', '--help', '--stuff', 'The remainder.'])
    assert args.match(tokens, 'word')
    assert args.match(tokens, 'option')
    assert args.match(tokens, 'int')
    assert args.match(tokens, 'option')
    assert args.match(tokens, 'option')
    assert args.match(tokens, 'string')

    # test a condition where there is a remainder that's not identified
    tokens = args.tokenize(['stop', '--pid', 'run/log.pid'])
    assert tokens
    assert args.match(tokens, 'word')
    assert args.match(tokens, 'option')
    assert args.match(tokens, 'string')
Exemplo n.º 5
0
def test_tokenize():
    tokens = args.tokenize(
        ['test', '--num', '1', '--help', '--stuff', 'The remainder.'])
    assert args.match(tokens, 'word')
    assert args.match(tokens, 'option')
    assert args.match(tokens, 'int')
    assert args.match(tokens, 'option')
    assert args.match(tokens, 'option')
    assert args.match(tokens, 'string')

    # test a condition where there is a remainder that's not identified
    tokens = args.tokenize(['stop', '--pid', 'run/log.pid'])
    assert tokens
    assert args.match(tokens, 'word')
    assert args.match(tokens, 'option')
    assert args.match(tokens, 'string')
def test_match():
    tokens = [["word", "test"],["int", 1]]
    assert args.match(tokens, "word") == "test", "Wrong word on match."
    assert args.match(tokens) == 1, "Wrong int on match."

    assert len(tokens) == 0, "There should be nothing in the array after matching."
def test_match_fails():
    tokens = [["word", "test"],["int", 1]]
    args.match(tokens, "string")
Exemplo n.º 8
0
def test_match_fails():
    tokens = [["word", "test"], ["int", 1]]
    args.match(tokens, "string")