Ejemplo n.º 1
0
def check_token(code, tokens):
    """Make sure that all tokens appears in code in order"""
    lx = XonshLexer()
    tks = list(lx.get_tokens(code))

    for tk in tokens:
        while tks:
            if tk == tks[0]:
                break
            tks = tks[1:]
        else:
            msg = "Token {!r} missing: {!r}".format(tk, list(lx.get_tokens(code)))
            pytest.fail(msg)
            break
Ejemplo n.º 2
0
def check_token(code, tokens):
    """Make sure that all tokens appears in code in order"""
    lx = XonshLexer()
    tks = list(lx.get_tokens(code))

    for tk in tokens:
        while tks:
            if tk == tks[0]:
                break
            tks = tks[1:]
        else:
            msg = "Token {!r} missing: {!r}".format(tk, list(lx.get_tokens(code)))
            pytest.fail(msg)
            break
Ejemplo n.º 3
0
    def factory(code, tokens):
        """Make sure that all tokens appears in code in order"""
        lx = XonshLexer()
        tks = list(lx.get_tokens(code))

        for tk in tokens:
            while tks:
                if tk == tks[0]:
                    break
                tks = tks[1:]
            else:
                msg = f"Token {tk!r} missing: {list(lx.get_tokens(code))!r}"
                pytest.fail(msg)
                break