from wizard import resolve def test_resolve_simple(): contents = """ foo bar <<<<<<< HEAD baz ======= boo >>>>>>> upstream bing """ spec = """ <<<<<<< baz ======= boo >>>>>>> """ result = [0] assert resolve.resolve(contents, spec, result) == """ foo bar boo bing """ def test_resolve_wildcard(): contents = """ foo bar <<<<<<< HEAD common uncommon still uncommon ======= transformed common >>>>>>> 456ef127bf8531bb363b1195172c71bce3747ae7 baz """ spec = """ <<<<<<< common ***1*** ======= transformed common >>>>>>> """ result = [0, 1] assert resolve.resolve(contents, spec, result) == """ foo bar transformed common uncommon still uncommon baz """ def test_resolve_user(): contents = """ top <<<<<<< bar the user is right baz ======= blah blah >>>>>>> bottom <<<<<<< Unrelated conflict ======= Unrelated conflicts >>>>>>>""" spec = """ <<<<<<< ***1*** the user is right ***2*** ======= blah blah >>>>>>> """ result = [-1] assert resolve.resolve(contents, spec, result) == """ top bar the user is right baz bottom <<<<<<< Unrelated conflict ======= Unrelated conflicts >>>>>>>""" def test_resolve_multi_var(): contents = """ top <<<<<<< the user is right this is ours more user stuff this is ours ======= this is kept, but variable this is not kept >>>>>>> bottom <<<<<<< unrelated conflict ======= unrelated conflicts >>>>>>> """ spec = """ <<<<<<< ***1*** this is ours ***2*** this is ours ======= ***3*** this is not kept >>>>>>> """ result = [3, 1, 2] assert resolve.resolve(contents, spec, result) == """ top this is kept, but variable the user is right more user stuff bottom <<<<<<< unrelated conflict ======= unrelated conflicts >>>>>>> """ def test_resolve_simple(): contents = """ bar <<<<<<< HEAD baz ======= boo >>>>>>> upstream bing <<<<<<< HEAD oh? ======= bad match >>>>>>> upstream """ spec = """ <<<<<<< ***1*** ======= bad match >>>>>>> """ result = [-1] assert resolve.resolve(contents, spec, result) == """ bar <<<<<<< HEAD baz ======= boo >>>>>>> upstream bing oh? """ def test_is_conflict(): assert not resolve.is_conflict("foobar\nbar") assert resolve.is_conflict("bar\n<<<<<<< HEAD\n=======\n>>>>>>> abcd\nbar")