X-Git-Url: https://scripts.mit.edu/gitweb/wizard.git/blobdiff_plain/48af129368493c5458c942aef025ed746b97b856..5b428fce4566ed627ad61f204935aaa8bc367932:/wizard/tests/resolve_test.py diff --git a/wizard/tests/resolve_test.py b/wizard/tests/resolve_test.py index ba5c2ee..10067f9 100644 --- a/wizard/tests/resolve_test.py +++ b/wizard/tests/resolve_test.py @@ -1,33 +1,67 @@ +import unittest + from wizard import resolve -def test_resolve_simple(): - contents = """ +class TestResolve(unittest.TestCase): + + def test_resolve_simple(self): + contents = """ foo bar <<<<<<< HEAD baz +||||||| +bal ======= boo >>>>>>> upstream bing """ - spec = """ + spec = """ <<<<<<< baz ======= boo >>>>>>> """ - result = [0] - assert resolve.resolve(contents, spec, result) == """ + result = [0] + self.assertEqual(resolve.resolve(contents, spec, result), """ foo bar boo bing +""") + + def test_resolve_simple_constrained(self): + contents = """ +1 +<<<<<<< HEAD +2.1 +||||||| +2 +======= +2.a +>>>>>>> upstream +3 +""" + spec = """ +<<<<<<< HEAD +2.1 +||||||| +2 +======= +2.a +>>>>>>> upstream """ + result = [0] + self.assertEqual(resolve.resolve(contents, spec, result), """ +1 +2.a +3 +""") -def test_resolve_wildcard(): - contents = """ + def test_resolve_wildcard(self): + contents = """ foo bar <<<<<<< HEAD @@ -35,13 +69,15 @@ common uncommon still uncommon +||||||| +something else ======= transformed common >>>>>>> 456ef127bf8531bb363b1195172c71bce3747ae7 baz """ - spec = """ + spec = """ <<<<<<< common ***1*** @@ -50,8 +86,8 @@ transformed common >>>>>>> """ - result = [0, 1] - assert resolve.resolve(contents, spec, result) == """ + result = [0, 1] + self.assertEqual(resolve.resolve(contents, spec, result), """ foo bar transformed common @@ -59,25 +95,29 @@ uncommon still uncommon baz -""" +""") -def test_resolve_user(): - contents = """ + def test_resolve_user(self): + contents = """ top <<<<<<< bar the user is right baz +||||||| +something wonderful ======= blah blah >>>>>>> bottom <<<<<<< Unrelated conflict +||||||| +something conflicty ======= Unrelated conflicts >>>>>>>""" - spec = """ + spec = """ <<<<<<< ***1*** the user is right @@ -86,8 +126,8 @@ the user is right blah blah >>>>>>> """ - result = [-1] - assert resolve.resolve(contents, spec, result) == """ + result = [-1] + self.assertEqual(resolve.resolve(contents, spec, result), """ top bar the user is right @@ -95,18 +135,22 @@ baz bottom <<<<<<< Unrelated conflict +||||||| +something conflicty ======= Unrelated conflicts ->>>>>>>""" +>>>>>>>""") -def test_resolve_multi_var(): - contents = """ + def test_resolve_multi_var(self): + contents = """ top <<<<<<< the user is right this is ours more user stuff this is ours +||||||| +Something special? ======= this is kept, but variable this is not kept @@ -114,11 +158,13 @@ this is not kept bottom <<<<<<< unrelated conflict +||||||| +original text of unrelated conflict ======= unrelated conflicts >>>>>>> """ - spec = """ + spec = """ <<<<<<< ***1*** this is ours @@ -129,8 +175,8 @@ this is ours this is not kept >>>>>>> """ - result = [3, 1, 2] - assert resolve.resolve(contents, spec, result) == """ + result = [3, 1, 2] + self.assertEqual(resolve.resolve(contents, spec, result), """ top this is kept, but variable the user is right @@ -138,44 +184,52 @@ more user stuff bottom <<<<<<< unrelated conflict +||||||| +original text of unrelated conflict ======= unrelated conflicts >>>>>>> -""" +""") -def test_resolve_simple(): - contents = """ + def test_resolve_multi_simple(self): + contents = """ bar <<<<<<< HEAD baz +||||||| +bollocks ======= boo >>>>>>> upstream bing <<<<<<< HEAD oh? +||||||| +puntful ======= bad match >>>>>>> upstream """ - spec = """ + spec = """ <<<<<<< ***1*** ======= bad match >>>>>>> """ - result = [-1] - assert resolve.resolve(contents, spec, result) == """ + result = [-1] + self.assertEqual(resolve.resolve(contents, spec, result), """ bar <<<<<<< HEAD baz +||||||| +bollocks ======= boo >>>>>>> upstream bing oh? -""" +""") def test_is_conflict(): assert not resolve.is_conflict("foobar\nbar")