Example #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
Example #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
Example #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
Example #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
Example #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
Example #6
0
def test_get_diff(extension):
    differ = CodeDiffer()
    a = 'some code...'
    b = 'some other code...'
    differ.get_diff(a=a, b=b, extension=extension)
Example #7
0
    def differ(self, value):
        if value == 'default':
            value = CodeDiffer()

        self._differ = value
Example #8
0
 def __init__(self):
     self.outdated_by_code = True
     self.cache_rendered_status = False
     self.hot_reload = False
     self.logging_factory = _logging_factory
     self.differ = CodeDiffer()