]> scripts.mit.edu Git - wizard.git/blobdiff - wizard/tests/resolve_test.py
Fix formatting bug.
[wizard.git] / wizard / tests / resolve_test.py
index 65e17d4d7b7a05144d0f89aff802d22d2cd35bcd..10067f9350f1a15781d2528e155a6bbc14bbdbd6 100644 (file)
@@ -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,28 +95,141 @@ 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
+***2***
 =======
 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
+baz
+bottom
+<<<<<<<
+Unrelated conflict
+|||||||
+something conflicty
+=======
+Unrelated conflicts
+>>>>>>>""")
+
+    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
+>>>>>>>
+bottom
+<<<<<<<
+unrelated conflict
+|||||||
+original text of unrelated conflict
+=======
+unrelated conflicts
+>>>>>>>
+"""
+        spec = """
+<<<<<<<
+***1***
+this is ours
+***2***
+this is ours
+=======
+***3***
+this is not kept
+>>>>>>>
+"""
+        result = [3, 1, 2]
+        self.assertEqual(resolve.resolve(contents, spec, result), """
 top
+this is kept, but variable
 the user is right
+more user stuff
+bottom
+<<<<<<<
+unrelated conflict
+|||||||
+original text of unrelated conflict
+=======
+unrelated conflicts
+>>>>>>>
+""")
+
+    def test_resolve_multi_simple(self):
+        contents = """
+bar
+<<<<<<< HEAD
+baz
+|||||||
+bollocks
+=======
+boo
+>>>>>>> upstream
+bing
+<<<<<<< HEAD
+oh?
+|||||||
+puntful
+=======
+bad match
+>>>>>>> upstream
+"""
+        spec = """
+<<<<<<<
+***1***
+=======
+bad match
+>>>>>>>
 """
+        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")