res = []
    for i in range(length):
        res.append(randint(0, max_value-1))

    return res


if __name__ == '__main__':
    for _ in range(100000):
        l1 = create_random_list(10, 10)
        l2 = create_random_list(10, 10)
        p = ListPatchExtractor(l1, l2)

        try:
            pl = patch(l1, p.patches)
            if l2 != pl:
                print l1
                print l2
                print
        except:
            print l1
            print l2
            print p.patches
            raise


'''
SOME SPECIAL CASES
old = [5]
new = [7,2,9,5,6,3,9]
Example #2
0
    },
    'listtest': [-1, 0, 1, 2, 4, 5, 6],
    'nested': [{
        'a': 1
    }, {
        'b': 2
    }],
    'object': b
}

patches = diff(old, new)

pprint(patches)
print

patched_obj = patch(old, patches)
pprint(patched_obj)
'''
from patch_extractor.dict_patch_extractor import DictPatchExtractor
from patch_extractor.list_patch_extractor import ListPatchExtractor
#from patch_extractor.actions import insert_action, delete_action
from patch_extractor.patcher import Patcher
from patch_filter import _resolve_list_problems

old = {'a': [1,2,3,4,5,6]}
new1 = {'a': [3,4,5,6]}
new2 = {'a': [1,2,5,6]}

e = DictPatchExtractor(old, new1, patch_extractors=[DictPatchExtractor, ListPatchExtractor])
e1 = DictPatchExtractor(old, new2, patch_extractors=[DictPatchExtractor, ListPatchExtractor])
Example #3
0
       'd': ['aa', 'abc'],  # Let's change something here
       'e': 2.2,            # Numbers should be easy     
       'g': 'added',        # added
       'insertthis': {'a':1, 'b': [1,2]},
       'changethis': {'a':2, 'b': [1]},
       'listtest':[-1, 0, 1, 2, 4, 5, 6],
       'nested':[{'a': 1}, {'b':2}],
       'object':b
       }

patches = diff(old, new)

pprint(patches)
print

patched_obj = patch(old, patches)
pprint(patched_obj)

'''
from patch_extractor.dict_patch_extractor import DictPatchExtractor
from patch_extractor.list_patch_extractor import ListPatchExtractor
#from patch_extractor.actions import insert_action, delete_action
from patch_extractor.patcher import Patcher
from patch_filter import _resolve_list_problems

old = {'a': [1,2,3,4,5,6]}
new1 = {'a': [3,4,5,6]}
new2 = {'a': [1,2,5,6]}

e = DictPatchExtractor(old, new1, patch_extractors=[DictPatchExtractor, ListPatchExtractor])
e1 = DictPatchExtractor(old, new2, patch_extractors=[DictPatchExtractor, ListPatchExtractor])