예제 #1
0
def assert_nodes_equal(x, y, include_attributes=True):
    if nodes_equal(x, y):
        return True
    if DEBUG_LEVEL > 0:
        print('x:\n==')
        print(pdump(x, include_attributes=include_attributes), '\n')
        print('y:\n==')
        print(pdump(y, include_attributes=include_attributes), '\n')
    assert_equal(pdump(x, include_attributes=include_attributes),
                 pdump(y, include_attributes=include_attributes))
예제 #2
0
def assert_nodes_equal(x, y, include_attributes=True):
    if nodes_equal(x, y):
        return True
    if DEBUG_LEVEL > 0:
        print('x:\n==')
        print(pdump(x, include_attributes=include_attributes), '\n')
        print('y:\n==')
        print(pdump(y, include_attributes=include_attributes), '\n')
    assert_equal(pdump(x, include_attributes=include_attributes),
                 pdump(y, include_attributes=include_attributes))
예제 #3
0
def assert_nodes_equal(x, y, include_attributes=True):
    __tracebackhide__ = True
    if nodes_equal(x, y):
        return True
    error_msg = 'x:\n=={}\ny:\n=={}\n'.format(
        pdump(x, include_attributes=include_attributes),
        pdump(y, include_attributes=include_attributes))
    if DEBUG_LEVEL > 0:
        print(error_msg, file=sys.stderr)
        pytest.fail(error_msg)
예제 #4
0
def test_formatting(inp, exp):
    execer = builtins.__xonsh__.execer
    # first check that we get what we expect
    try:
        obs = reformat(inp)
    except TypeError:
        print("Formatter failed!")
        pprint_ast(execer.parse(inp, {}))
        raise
    assert exp == obs, "Bad Tree:\n" + pdump(execer.parse(inp, {}))
    # next check that the transformation is stable
    obs2 = reformat(obs)
    assert obs == obs2
    # last, check that the initial AST is the same as the AST we produced
    # using the normal xonsh parser, barring line & column numbers
    exp_tree = execer.parse(exp, {})
    obs_tree = execer.parse(obs, {})
    assert nodes_equal(exp_tree, obs_tree, check_attributes=False)