Beispiel #1
0
def test_different_params():
    differ = CodeDiffer()
    res, _ = differ.is_different(a='some code',
                                 b='some code',
                                 a_params={'a': 1},
                                 b_params={'a': 2},
                                 extension='py')
    assert res
Beispiel #2
0
def test_python_differ_ignores_docstrings():

    differ = CodeDiffer()
    res, _ = differ.is_different(a=fn_w_docsting,
                                 b=fn_w_docsting_v2,
                                 a_params={},
                                 b_params={},
                                 extension='py')
    assert not res
Beispiel #3
0
def test_different_with_unserializable_params(a_params, b_params, expected):
    differ = CodeDiffer()

    res, _ = differ.is_different(a='some code',
                                 b='some code',
                                 a_params=a_params,
                                 b_params=b_params,
                                 extension='py')

    assert res is expected
Beispiel #4
0
def test_sql_is_normalized():
    a = """
    SELECT * FROM TABLE
    """

    b = """
    SELECT *
    FROM table
    """
    differ = CodeDiffer()
    different, _ = differ.is_different(a=a,
                                       b=b,
                                       a_params={},
                                       b_params={},
                                       extension='sql')
    assert not different
Beispiel #5
0
def test_python_differ_ignores_comments():

    a = '''
def x():
    # this is a comment
    # another comment
    var = 100
'''

    b = '''
def x():
    # one comment
    var = 100 # this is a comment
'''

    differ = CodeDiffer()
    res, _ = differ.is_different(a=a,
                                 b=b,
                                 a_params={},
                                 b_params={},
                                 extension='py')
    assert not res